当前位置: 首页>>代码示例>>Golang>>正文


Golang featureflag.SetFlagsFromEnvironment函数代码示例

本文整理汇总了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)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:25,代码来源:base.go

示例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"`)
}
开发者ID:rogpeppe,项目名称:juju-utils,代码行数:7,代码来源:flags_test.go

示例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, "")
}
开发者ID:rogpeppe,项目名称:juju-utils,代码行数:7,代码来源:flags_test.go

示例4: init

func init() {
	if FLAGSFROMENVIRONMENT == "true" {
		featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
	} else {
		featureflag.SetFlagsFromRegistry(osenv.JujuRegistryKey, osenv.JujuFeatureFlagEnvKey)
	}
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:main_windows.go

示例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)
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:8,代码来源:base.go

示例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
}
开发者ID:makyo,项目名称:juju,代码行数:10,代码来源:bootstrap.go

示例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)
}
开发者ID:rogpeppe,项目名称:juju-utils,代码行数:12,代码来源:flags_test.go

示例8: init

func init() {
	featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
开发者ID:Pankov404,项目名称:juju,代码行数:3,代码来源:main_nix.go

示例9: enableFeatureFlag

func (s *AddressableContainerSetupSuite) enableFeatureFlag() {
	s.SetFeatureFlags(feature.AddressAllocation)
	featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
开发者ID:chrisjohnston,项目名称:juju,代码行数:4,代码来源:container_initialisation_test.go

示例10: setFeatureFlags

func setFeatureFlags(flags string) {
	if err := os.Setenv(osenv.JujuFeatureFlagEnvKey, flags); err != nil {
		panic(err)
	}
	featureflag.SetFlagsFromEnvironment(osenv.JujuFeatureFlagEnvKey)
}
开发者ID:kat-co,项目名称:juju,代码行数:6,代码来源:main_test.go

示例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)
}
开发者ID:imoapps,项目名称:juju,代码行数:5,代码来源:discovery_test.go

示例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)
}
开发者ID:Pankov404,项目名称:juju,代码行数:5,代码来源:base_unix.go


注:本文中的github.com/juju/utils/featureflag.SetFlagsFromEnvironment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。