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


Golang environs.Provider函数代码示例

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


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

示例1: TestNullAlias

func (s *providerSuite) TestNullAlias(c *gc.C) {
	p, err := environs.Provider("manual")
	c.Assert(p, gc.NotNil)
	c.Assert(err, jc.ErrorIsNil)
	p, err = environs.Provider("null")
	c.Assert(p, gc.NotNil)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:imoapps,项目名称:juju,代码行数:8,代码来源:provider_test.go

示例2: finalizeConfig

// finalizeConfig creates the config object from attributes, calls
// PrepareForCreateEnvironment, and then finally validates the config
// before returning it.
func finalizeConfig(isAdmin bool, controllerCfg *config.Config, attrs map[string]interface{}) (*config.Config, error) {
	provider, err := environs.Provider(controllerCfg.Type())
	if err != nil {
		return nil, errors.Trace(err)
	}

	// Controller admins creating models do not have to re-supply new secrets.
	// These may be copied from the controller model if not supplied.
	if isAdmin {
		maybeCopyControllerSecrets(provider, controllerCfg.AllAttrs(), attrs)
	}
	cfg, err := config.New(config.UseDefaults, attrs)
	if err != nil {
		return nil, errors.Annotate(err, "creating config from values failed")
	}

	cfg, err = provider.PrepareForCreateEnvironment(cfg)
	if err != nil {
		return nil, errors.Trace(err)
	}
	cfg, err = provider.Validate(cfg, nil)
	if err != nil {
		return nil, errors.Annotate(err, "provider validation failed")
	}
	return cfg, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:29,代码来源:createmodel.go

示例3: init

func init() {
	dummyProvider, err := environs.Provider("dummy")
	if err != nil {
		panic(err)
	}
	environs.RegisterProvider("fake", mockProvider{dummyProvider})
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:credentials_test.go

示例4: testToolsMetadata

func (s *BootstrapSuite) testToolsMetadata(c *gc.C, exploded bool) {
	provider, err := environs.Provider(s.envcfg.Type())
	c.Assert(err, gc.IsNil)
	env, err := provider.Open(s.envcfg)
	c.Assert(err, gc.IsNil)
	oldMetadata, err := envtools.ReadMetadata(env.Storage())
	c.Assert(err, gc.IsNil)

	_, cmd, err := s.initBootstrapCommand(c, nil, "--env-config", s.b64yamlEnvcfg, "--instance-id", string(s.instanceId))
	c.Assert(err, gc.IsNil)
	err = cmd.Run(nil)
	c.Assert(err, gc.IsNil)

	newMetadata, err := envtools.ReadMetadata(env.Storage())
	c.Assert(err, gc.IsNil)
	if !exploded {
		c.Assert(newMetadata, gc.HasLen, len(oldMetadata))
	} else {
		// new metadata should have more tools.
		c.Assert(len(newMetadata), jc.GreaterThan, len(oldMetadata))
		var expectedSeries set.Strings
		for _, series := range version.SupportedSeries() {
			os, err := version.GetOSFromSeries(series)
			c.Assert(err, gc.IsNil)
			if os == version.Ubuntu {
				expectedSeries.Add(series)
			}
		}
		c.Assert(newMetadata, gc.HasLen, expectedSeries.Size())
		for _, m := range newMetadata {
			c.Assert(expectedSeries.Contains(m.Release), jc.IsTrue)
		}
	}
}
开发者ID:kapilt,项目名称:juju,代码行数:34,代码来源:bootstrap_test.go

示例5: prepare

func (c *imageMetadataCommandBase) prepare(context *cmd.Context) (environs.Environ, error) {
	// NOTE(axw) this is a work-around for the TODO below. This
	// means that the command will only work if you've bootstrapped
	// the specified environment.
	bootstrapConfig, params, err := modelcmd.NewGetBootstrapConfigParamsFunc(context, c.ClientStore())(c.ControllerName())
	if err != nil {
		return nil, errors.Trace(err)
	}
	provider, err := environs.Provider(bootstrapConfig.CloudType)
	if err != nil {
		return nil, errors.Trace(err)
	}
	cfg, err := provider.PrepareConfig(*params)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// TODO(axw) we'll need to revise the metadata commands to work
	// without preparing an environment. They should take the same
	// format as bootstrap, i.e. cloud/region, and we'll use that to
	// identify region and endpoint info that we need. Not sure what
	// we'll do about simplestreams.MetadataValidator yet. Probably
	// move it to the EnvironProvider interface.
	return environs.New(environs.OpenParams{
		Cloud:  params.Cloud,
		Config: cfg,
	})
}
开发者ID:bac,项目名称:juju,代码行数:27,代码来源:imagemetadata.go

示例6: SetUpTest

func (s *credentialsSuite) SetUpTest(c *gc.C) {
	s.IsolationSuite.SetUpTest(c)

	var err error
	s.provider, err = environs.Provider("gce")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:7,代码来源:credentials_test.go

示例7: TestProvidersAreRegistered

func (s *MainSuite) TestProvidersAreRegistered(c *gc.C) {
	// check that all the expected providers are registered
	for _, name := range expectedProviders {
		_, err := environs.Provider(name)
		c.Assert(err, jc.ErrorIsNil)
	}
}
开发者ID:Pankov404,项目名称:juju,代码行数:7,代码来源:main_test.go

示例8: SetUpTest

func (s *providerSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	var err error
	s.provider, err = environs.Provider("gce")
	c.Check(err, jc.ErrorIsNil)
}
开发者ID:pmatulis,项目名称:juju,代码行数:7,代码来源:provider_test.go

示例9: ModelConfig

// ModelConfig returns the current environment's configuration.
func (e *ModelWatcher) ModelConfig() (params.ModelConfigResult, error) {
	result := params.ModelConfigResult{}

	config, err := e.st.ModelConfig()
	if err != nil {
		return result, err
	}
	allAttrs := config.AllAttrs()

	if !e.authorizer.AuthModelManager() {
		// Mask out any secrets in the environment configuration
		// with values of the same type, so it'll pass validation.
		//
		// TODO(dimitern) 201309-26 bug #1231384
		// Delete the code below and mark the bug as fixed,
		// once it's live tested on MAAS and 1.16 compatibility
		// is dropped.
		provider, err := environs.Provider(config.Type())
		if err != nil {
			return result, err
		}
		secretAttrs, err := provider.SecretAttrs(config)
		for k := range secretAttrs {
			allAttrs[k] = "not available"
		}
	}
	result.Config = allAttrs
	return result, nil
}
开发者ID:pmatulis,项目名称:juju,代码行数:30,代码来源:modelwatcher.go

示例10: builtInProviders

// builtInProviders returns cloud information for those
// providers which are built in to Juju.
func builtInProviders() map[string]jujucloud.Cloud {
	builtIn := make(map[string]jujucloud.Cloud)
	for _, name := range jujucloud.BuiltInProviderNames {
		provider, err := environs.Provider(name)
		if err != nil {
			// Should never happen but it will on go 1.2
			// because lxd provider is not built.
			logger.Warningf("cloud %q not available on this platform", name)
			continue
		}
		var regions []jujucloud.Region
		if detector, ok := provider.(environs.CloudRegionDetector); ok {
			regions, err = detector.DetectRegions()
			if err != nil && !errors.IsNotFound(err) {
				logger.Warningf("could not detect regions for %q: %v", name, err)
			}
		}
		cloud := jujucloud.Cloud{
			Type:    name,
			Regions: regions,
		}
		schema := provider.CredentialSchemas()
		for authType := range schema {
			if authType == jujucloud.EmptyAuthType {
				continue
			}
			cloud.AuthTypes = append(cloud.AuthTypes, authType)
		}
		builtIn[name] = cloud
	}
	return builtIn
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:34,代码来源:list.go

示例11: SetUpTest

func (s *providerSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)

	provider, err := environs.Provider("lxd")
	c.Assert(err, jc.ErrorIsNil)
	s.provider = provider
}
开发者ID:exekias,项目名称:juju,代码行数:7,代码来源:provider_test.go

示例12: makeTestEnv

func (s *BootstrapSuite) makeTestEnv(c *gc.C) {
	attrs := dummy.SampleConfig().Merge(
		testing.Attrs{
			"agent-version":     version.Current.Number.String(),
			"bootstrap-timeout": "123",
		},
	).Delete("admin-secret", "ca-private-key")
	cfg, err := config.New(config.NoDefaults, attrs)
	c.Assert(err, jc.ErrorIsNil)
	provider, err := environs.Provider(cfg.Type())
	c.Assert(err, jc.ErrorIsNil)
	env, err := provider.PrepareForBootstrap(nullContext(), cfg)
	c.Assert(err, jc.ErrorIsNil)

	envtesting.MustUploadFakeTools(s.toolsStorage, cfg.AgentStream(), cfg.AgentStream())
	inst, _, _, err := jujutesting.StartInstance(env, "0")
	c.Assert(err, jc.ErrorIsNil)
	s.instanceId = inst.Id()

	addresses, err := inst.Addresses()
	c.Assert(err, jc.ErrorIsNil)
	s.bootstrapName = network.SelectPublicAddress(addresses)
	s.envcfg = env.Config()
	s.b64yamlEnvcfg = b64yaml(s.envcfg.AllAttrs()).encode()
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:25,代码来源:bootstrap_test.go

示例13: SetUpTest

func (s *credentialsSuite) SetUpTest(c *gc.C) {
	s.FakeHomeSuite.SetUpTest(c)

	var err error
	s.provider, err = environs.Provider("maas")
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:7,代码来源:credentials_test.go

示例14: SetUpTest

func (s *providerSuite) SetUpTest(c *gc.C) {
	s.IsolationSuite.SetUpTest(c)

	provider, err := environs.Provider("joyent")
	c.Assert(err, jc.ErrorIsNil)
	s.provider = provider
	s.spec = fakeCloudSpec()
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:provider_test.go

示例15: RestrictedProviderFields

// RestrictedProviderFields returns the set of config fields that may not be
// overridden.
func RestrictedProviderFields(providerType string) ([]string, error) {
	provider, err := environs.Provider(providerType)
	if err != nil {
		return nil, errors.Trace(err)
	}
	var fields []string
	fields = append(fields, configValuesFromController...)
	fields = append(fields, provider.RestrictedConfigAttributes()...)
	return fields, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:12,代码来源:createmodel.go


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