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


Golang featureflag.Enabled函数代码示例

本文整理汇总了Golang中github.com/juju/utils/featureflag.Enabled函数的典型用法代码示例。如果您正苦于以下问题:Golang Enabled函数的具体用法?Golang Enabled怎么用?Golang Enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Enabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: addRequiredPackages

// addRequiredPackages is defined on the AdvancedPackagingConfig interface.
func (cfg *centOSCloudConfig) addRequiredPackages() {
	packages := []string{
		"curl",
		"bridge-utils",
		"cloud-utils",
		"nmap-ncat",
		"tmux",
	}
	if featureflag.Enabled(feature.DeveloperMode) {
		packages = append(packages, "socat")
	}

	// The required packages need to come from the correct repo.
	// For CentOS 7, this requires an rpm cloud archive be up.
	// In the event of the addition of such a repository, its addition should
	// happen in the utils/packaging/config package whilst leaving the below
	// code untouched.
	for _, pack := range packages {
		if config.SeriesRequiresCloudArchiveTools(cfg.series) && cfg.pacconfer.IsCloudArchivePackage(pack) {
			cfg.AddPackage(strings.Join(cfg.pacconfer.ApplyCloudArchiveTarget(pack), " "))
		} else {
			cfg.AddPackage(pack)
		}
	}
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:cloudinit_centos.go

示例2: versionInitSystem

func versionInitSystem(ser string) (string, error) {
	seriesos, err := series.GetOSFromSeries(ser)
	if err != nil {
		notFound := errors.NotFoundf("init system for series %q", ser)
		return "", errors.Wrap(err, notFound)
	}

	switch seriesos {
	case os.Windows:
		return InitSystemWindows, nil
	case os.Ubuntu:
		switch ser {
		case "precise", "quantal", "raring", "saucy", "trusty", "utopic":
			return InitSystemUpstart, nil
		default:
			// vivid and later
			if featureflag.Enabled(feature.LegacyUpstart) {
				return InitSystemUpstart, nil
			}
			return InitSystemSystemd, nil
		}
	case os.CentOS:
		return InitSystemSystemd, nil
	}
	return "", errors.NotFoundf("unknown os %q (from series %q), init system", seriesos, ser)
}
开发者ID:imoapps,项目名称:juju,代码行数:26,代码来源:discovery.go

示例3: decorateAndWriteInfo

// decorateAndWriteInfo decorates the info struct with information
// from the given cfg, and the writes that out to the filesystem.
func decorateAndWriteInfo(info configstore.EnvironInfo, cfg *config.Config) error {

	// Sanity check our config.
	var endpoint configstore.APIEndpoint
	if cert, ok := cfg.CACert(); !ok {
		return errors.Errorf("CACert is not set")
	} else if uuid, ok := cfg.UUID(); !ok {
		return errors.Errorf("UUID is not set")
	} else if adminSecret := cfg.AdminSecret(); adminSecret == "" {
		return errors.Errorf("admin-secret is not set")
	} else {
		endpoint = configstore.APIEndpoint{
			CACert:      cert,
			EnvironUUID: uuid,
		}
	}

	creds := configstore.APICredentials{
		User:     configstore.DefaultAdminUsername,
		Password: cfg.AdminSecret(),
	}
	if featureflag.Enabled(feature.JES) {
		endpoint.ServerUUID = endpoint.EnvironUUID
	}
	info.SetAPICredentials(creds)
	info.SetAPIEndpoint(endpoint)
	info.SetBootstrapConfig(cfg.AllAttrs())

	if err := info.Write(); err != nil {
		return errors.Annotatef(err, "cannot create environment info %q", cfg.Name())
	}

	return nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:36,代码来源:open.go

示例4: DestroyController

// DestroyController implements the Environ interface.
func (e *manualEnviron) DestroyController(controllerUUID string) error {
	script := `
set -x
touch %s
# If jujud is running, we then wait for a while for it to stop.
stopped=0
if pkill -%d jujud; then
    for i in ` + "`seq 1 30`" + `; do
        if pgrep jujud > /dev/null ; then
            sleep 1
        else
            echo "jujud stopped"
            stopped=1
            break
        fi
    done
fi
if [ $stopped -ne 1 ]; then
    # If jujud didn't stop nicely, we kill it hard here.
    %spkill -9 jujud
    service %s stop
fi
rm -f /etc/init/juju*
rm -f /etc/systemd/system/juju*
rm -fr %s %s
exit 0
`
	var diagnostics string
	if featureflag.Enabled(feature.DeveloperMode) {
		diagnostics = `
    echo "Dump engine report and goroutines for stuck jujud"
    source /etc/profile.d/juju-introspection.sh
    juju-engine-report
    juju-goroutines
`
	}
	script = fmt.Sprintf(
		script,
		// WARNING: this is linked with the use of uninstallFile in
		// the agent package. Don't change it without extreme care,
		// and handling for mismatches with already-deployed agents.
		utils.ShQuote(path.Join(
			agent.DefaultPaths.DataDir,
			agent.UninstallFile,
		)),
		terminationworker.TerminationSignal,
		diagnostics,
		mongo.ServiceName,
		utils.ShQuote(agent.DefaultPaths.DataDir),
		utils.ShQuote(agent.DefaultPaths.LogDir),
	)
	logger.Tracef("destroy controller script: %s", script)
	stdout, stderr, err := runSSHCommand(
		"[email protected]"+e.host,
		[]string{"sudo", "/bin/bash"}, script,
	)
	logger.Debugf("script stdout: \n%s", stdout)
	logger.Debugf("script stderr: \n%s", stderr)
	return err
}
开发者ID:kat-co,项目名称:juju,代码行数:61,代码来源:environ.go

示例5: 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

示例6: lookup

// lookup translates a facade name and version into a facadeRecord.
func (f *FacadeRegistry) lookup(name string, version int) (facadeRecord, error) {
	if versions, ok := f.facades[name]; ok {
		if record, ok := versions[version]; ok {
			if featureflag.Enabled(record.feature) {
				return record, nil
			}
		}
	}
	return facadeRecord{}, errors.NotFoundf("%s(%d)", name, version)
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:registry.go

示例7: Write

// Write implements EnvironInfo.Write.
func (info *environInfo) Write() error {
	info.mu.Lock()
	defer info.mu.Unlock()
	lock, err := acquireEnvironmentLock(info.environmentDir, "writing")
	if err != nil {
		return errors.Annotatef(err, "cannot write info")
	}
	defer lock.Unlock()

	// In order to write out the environment info to the cache
	// file we need to make sure the server UUID is set. Sufficiently
	// up to date servers will write the server UUID to the JENV
	// file as connections are made to the API server. It is possible
	// that for an old JENV file, the first update (on API connection)
	// may write a JENV file, and the subsequent update will create the
	// entry in the cache file.
	// If the source was the cache file, then always write there to
	// avoid stale data in the cache file.
	if info.source == sourceCache ||
		(featureflag.Enabled(feature.JES) && info.serverUUID != "") {
		if err := info.ensureNoJENV(); info.source == sourceCreated && err != nil {
			return errors.Trace(err)
		}
		logger.Debugf("writing cache file")
		filename := cacheFilename(info.environmentDir)
		cache, err := readCacheFile(filename)
		if err != nil {
			return errors.Trace(err)
		}
		if err := cache.updateInfo(info); err != nil {
			return errors.Trace(err)
		}
		if err := writeCacheFile(filename, cache); err != nil {
			return errors.Trace(err)
		}
		oldPath := info.path
		info.path = filename
		// If source was jenv file, delete the jenv.
		if info.source == sourceJenv {
			err := os.Remove(oldPath)
			if err != nil {
				return errors.Trace(err)
			}
		}
		info.source = sourceCache
	} else {
		logger.Debugf("writing jenv file")
		if err := info.writeJENVFile(); err != nil {
			return errors.Trace(err)
		}
		info.source = sourceJenv
	}
	return nil
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:55,代码来源:disk.go

示例8: descriptionFromVersions

// descriptionFromVersions aggregates the information in a versions map into a
// more friendly form for List().
func descriptionFromVersions(name string, vers versions) FacadeDescription {
	intVersions := make([]int, 0, len(vers))
	for version, record := range vers {
		if featureflag.Enabled(record.feature) {
			intVersions = append(intVersions, version)
		}
	}
	sort.Ints(intVersions)
	return FacadeDescription{
		Name:     name,
		Versions: intVersions,
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:15,代码来源:registry.go

示例9: SetFlags

func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
	f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "set model constraints")
	f.Var(constraints.ConstraintsValue{Target: &c.BootstrapConstraints}, "bootstrap-constraints", "specify bootstrap machine constraints")
	f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "specify the series of the bootstrap machine")
	if featureflag.Enabled(feature.ImageMetadata) {
		f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "specify the image of the bootstrap machine")
	}
	f.BoolVar(&c.UploadTools, "upload-tools", false, "upload local version of tools before bootstrapping")
	f.StringVar(&c.MetadataSource, "metadata-source", "", "local path to use as tools and/or metadata source")
	f.StringVar(&c.Placement, "to", "", "a placement directive indicating an instance to bootstrap")
	f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "do not destroy the model if bootstrap fails")
	f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "upgrade to the latest patch release tools on first bootstrap")
	f.StringVar(&c.AgentVersionParam, "agent-version", "", "the version of tools to use for Juju agents")
}
开发者ID:exekias,项目名称:juju,代码行数:14,代码来源:bootstrap.go

示例10: SetUpTest

func (s *BaseSubnetSuite) SetUpTest(c *gc.C) {
	// If any post-MVP command suite enabled the flag, keep it.
	hasFeatureFlag := featureflag.Enabled(feature.PostNetCLIMVP)

	s.FakeJujuXDGDataHomeSuite.SetUpTest(c)

	if hasFeatureFlag {
		s.FakeJujuXDGDataHomeSuite.SetFeatureFlags(feature.PostNetCLIMVP)
	}

	s.api = NewStubAPI()
	c.Assert(s.api, gc.NotNil)

	// All subcommand suites embedding this one should initialize
	// s.command immediately after calling this method!
}
开发者ID:bac,项目名称:juju,代码行数:16,代码来源:package_test.go

示例11: NewSuperCommand

// NewSuperCommand creates the "subnet" supercommand and registers the
// subcommands that it supports.
func NewSuperCommand() cmd.Command {
	subnetCmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "subnet",
		Doc:         strings.TrimSpace(commandDoc),
		UsagePrefix: "juju",
		Purpose:     "manage subnets",
	})
	subnetCmd.Register(envcmd.Wrap(&AddCommand{}))
	subnetCmd.Register(envcmd.Wrap(&ListCommand{}))
	if featureflag.Enabled(feature.PostNetCLIMVP) {
		// The following commands are not part of the MVP.
		subnetCmd.Register(envcmd.Wrap(&CreateCommand{}))
		subnetCmd.Register(envcmd.Wrap(&RemoveCommand{}))
	}

	return subnetCmd
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:19,代码来源:subnet.go

示例12: 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

示例13: TestEnabled

func (s *flagWinSuite) TestEnabled(c *gc.C) {
	c.Assert(featureflag.Enabled(""), jc.IsTrue)
	c.Assert(featureflag.Enabled(" "), jc.IsTrue)
	c.Assert(featureflag.Enabled("magic"), jc.IsFalse)

	s.k.SetStringValue("JUJU_TESTING_FEATURE", "MAGIC")
	featureflag.SetFlagsFromRegistry(regKey, "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:juju,项目名称:utils,代码行数:12,代码来源:flags_windows_test.go

示例14: NewSuperCommand

// NewSuperCommand creates the "space" supercommand and registers the
// subcommands that it supports.
func NewSuperCommand() cmd.Command {
	spaceCmd := cmd.NewSuperCommand(cmd.SuperCommandParams{
		Name:        "space",
		Doc:         strings.TrimSpace(commandDoc),
		UsagePrefix: "juju",
		Purpose:     "manage network spaces",
	})
	spaceCmd.Register(newCreateCommand())
	spaceCmd.Register(newListCommand())
	if featureflag.Enabled(feature.PostNetCLIMVP) {
		// The following commands are not part of the MVP.
		spaceCmd.Register(newRemoveCommand())
		spaceCmd.Register(newUpdateCommand())
		spaceCmd.Register(newRenameCommand())
	}

	return spaceCmd
}
开发者ID:imoapps,项目名称:juju,代码行数:20,代码来源:space.go

示例15: SetFlags

func (c *bootstrapCommand) SetFlags(f *gnuflag.FlagSet) {
	f.Var(constraints.ConstraintsValue{Target: &c.Constraints}, "constraints", "Set model constraints")
	f.Var(constraints.ConstraintsValue{Target: &c.BootstrapConstraints}, "bootstrap-constraints", "Specify bootstrap machine constraints")
	f.StringVar(&c.BootstrapSeries, "bootstrap-series", "", "Specify the series of the bootstrap machine")
	if featureflag.Enabled(feature.ImageMetadata) {
		f.StringVar(&c.BootstrapImage, "bootstrap-image", "", "Specify the image of the bootstrap machine")
	}
	f.BoolVar(&c.UploadTools, "upload-tools", false, "Upload local version of tools before bootstrapping")
	f.StringVar(&c.MetadataSource, "metadata-source", "", "Local path to use as tools and/or metadata source")
	f.StringVar(&c.Placement, "to", "", "Placement directive indicating an instance to bootstrap")
	f.BoolVar(&c.KeepBrokenEnvironment, "keep-broken", false, "Do not destroy the model if bootstrap fails")
	f.BoolVar(&c.AutoUpgrade, "auto-upgrade", false, "Upgrade to the latest patch release tools on first bootstrap")
	f.StringVar(&c.AgentVersionParam, "agent-version", "", "Version of tools to use for Juju agents")
	f.StringVar(&c.CredentialName, "credential", "", "Credentials to use when bootstrapping")
	f.Var(&c.config, "config", "Specify a controller configuration file, or one or more configuration\n    options\n    (--config config.yaml [--config key=value ...])")
	f.StringVar(&c.hostedModelName, "d", defaultHostedModelName, "Name of the default hosted model for the controller")
	f.StringVar(&c.hostedModelName, "default-model", defaultHostedModelName, "Name of the default hosted model for the controller")
	f.BoolVar(&c.noGUI, "no-gui", false, "Do not install the Juju GUI in the controller when bootstrapping")
}
开发者ID:makyo,项目名称:juju,代码行数:19,代码来源:bootstrap.go


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