本文整理汇总了Golang中github.com/juju/utils/featureflag.SetFlagsFromEnvironment函数的典型用法代码示例。如果您正苦于以下问题:Golang SetFlagsFromEnvironment函数的具体用法?Golang SetFlagsFromEnvironment怎么用?Golang SetFlagsFromEnvironment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetFlagsFromEnvironment函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: SetUpTest
func (s *JujuOSEnvSuite) SetUpTest(c *gc.C) {
s.oldEnvironment = make(map[string]string)
for _, name := range []string{
osenv.JujuXDGDataHomeEnvKey,
osenv.JujuModelEnvKey,
osenv.JujuLoggingConfigEnvKey,
osenv.JujuFeatureFlagEnvKey,
osenv.XDGDataHome,
} {
s.oldEnvironment[name] = os.Getenv(name)
os.Setenv(name, "")
}
s.oldHomeEnv = utils.Home()
s.oldJujuXDGDataHome = osenv.SetJujuXDGDataHome("")
utils.SetHome("")
// Update the feature flag set to be the requested initial set.
// This works for both windows and unix, even though normally
// the feature flags on windows are determined using the registry.
// For tests, setting with the environment variable isolates us
// from a single resource that was hitting contention during parallel
// test runs.
os.Setenv(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例2: TestParsing
func (s *flagSuite) TestParsing(c *gc.C) {
s.PatchEnvironment("JUJU_TESTING_FEATURE", "MAGIC, test, space ")
featureflag.SetFlagsFromEnvironment("JUJU_TESTING_FEATURE")
c.Assert(featureflag.All(), jc.SameContents, []string{"magic", "space", "test"})
c.Assert(featureflag.AsEnvironmentValue(), gc.Equals, "magic,space,test")
c.Assert(featureflag.String(), gc.Equals, `"magic", "space", "test"`)
}
示例3: TestEmpty
func (s *flagSuite) TestEmpty(c *gc.C) {
s.PatchEnvironment("JUJU_TESTING_FEATURE", "")
featureflag.SetFlagsFromEnvironment("JUJU_TESTING_FEATURE")
c.Assert(featureflag.All(), gc.HasLen, 0)
c.Assert(featureflag.AsEnvironmentValue(), gc.Equals, "")
c.Assert(featureflag.String(), gc.Equals, "")
}
示例4: init
func init() {
if FLAGSFROMENVIRONMENT == "true" {
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
} else {
featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
}
}
示例5: SetFeatureFlags
func (s *JujuOSEnvSuite) SetFeatureFlags(flag ...string) {
flags := strings.Join(flag, ",")
if err := os.Setenv(osenv.JujuFeatureFlagEnvKey, flags); err != nil {
panic(err)
}
logger.Debugf("setting feature flags: %s", flags)
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例6: checkProviderType
// checkProviderType ensures the provider type is okay.
func checkProviderType(envType string) error {
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
flag, ok := provisionalProviders[envType]
if ok && !featureflag.Enabled(flag) {
msg := `the %q provider is provisional in this version of Juju. To use it anyway, set JUJU_DEV_FEATURE_FLAGS="%s" in your shell model`
return errors.Errorf(msg, envType, flag)
}
return nil
}
示例7: TestEnabled
func (s *flagSuite) TestEnabled(c *gc.C) {
c.Assert(featureflag.Enabled(""), jc.IsTrue)
c.Assert(featureflag.Enabled(" "), jc.IsTrue)
c.Assert(featureflag.Enabled("magic"), jc.IsFalse)
s.PatchEnvironment("JUJU_TESTING_FEATURE", "MAGIC")
featureflag.SetFlagsFromEnvironment("JUJU_TESTING_FEATURE")
c.Assert(featureflag.Enabled("magic"), jc.IsTrue)
c.Assert(featureflag.Enabled("Magic"), jc.IsTrue)
c.Assert(featureflag.Enabled(" MAGIC "), jc.IsTrue)
}
示例8: init
func init() {
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例9: enableFeatureFlag
func (s *AddressableContainerSetupSuite) enableFeatureFlag() {
s.SetFeatureFlags(feature.AddressAllocation)
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例10: setFeatureFlags
func setFeatureFlags(flags string) {
if err := os.Setenv(osenv.JujuFeatureFlagEnvKey, flags); err != nil {
panic(err)
}
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例11: setLegacyUpstart
func (s *discoverySuite) setLegacyUpstart(c *gc.C) {
err := os.Setenv(osenv.JujuFeatureFlagEnvKey, feature.LegacyUpstart)
c.Assert(err, jc.ErrorIsNil)
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
示例12: setUpFeatureFlags
// setUpFeatureFlags sets the feature flags from the environment.
func (s *JujuOSEnvSuite) setUpFeatureFlags(c *gc.C) {
os.Setenv(osenv.JujuFeatureFlagEnvKey, s.initialFeatureFlags)
featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}