github.com/altoros/juju-vmware@v0.0.0-20150312064031-f19ae857ccca/juju/osenv/vars.go (about) 1 // Copyright 2013 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package osenv 5 6 import "github.com/juju/utils/featureflag" 7 8 const ( 9 JujuEnvEnvKey = "JUJU_ENV" 10 JujuHomeEnvKey = "JUJU_HOME" 11 JujuRepositoryEnvKey = "JUJU_REPOSITORY" 12 JujuLoggingConfigEnvKey = "JUJU_LOGGING_CONFIG" 13 JujuFeatureFlagEnvKey = "JUJU_DEV_FEATURE_FLAGS" 14 // TODO(thumper): 2013-09-02 bug 1219630 15 // As much as I'd like to remove JujuContainerType now, it is still 16 // needed as MAAS still needs it at this stage, and we can't fix 17 // everything at once. 18 JujuContainerTypeEnvKey = "JUJU_CONTAINER_TYPE" 19 ) 20 21 // FeatureFlags returns a map that can be merged with os.Environ. 22 func FeatureFlags() map[string]string { 23 result := make(map[string]string) 24 if envVar := featureflag.AsEnvironmentValue(); envVar != "" { 25 result[JujuFeatureFlagEnvKey] = envVar 26 } 27 return result 28 } 29 30 // MergeEnvironment will return the current environment updated with 31 // all the values from newValues. If current is nil, a new map is 32 // created. If current is not nil, it is mutated. 33 func MergeEnvironment(current, newValues map[string]string) map[string]string { 34 if current == nil { 35 current = make(map[string]string) 36 } 37 for key, value := range newValues { 38 current[key] = value 39 } 40 return current 41 }