本文整理汇总了Golang中github.com/juju/juju/environs.EnvironProvider.Open方法的典型用法代码示例。如果您正苦于以下问题:Golang EnvironProvider.Open方法的具体用法?Golang EnvironProvider.Open怎么用?Golang EnvironProvider.Open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs.EnvironProvider
的用法示例。
在下文中一共展示了EnvironProvider.Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: openEnviron
func openEnviron(
c *gc.C,
provider environs.EnvironProvider,
sender *azuretesting.Senders,
attrs ...testing.Attrs,
) environs.Environ {
// Opening the environment should not incur network communication,
// so we don't set s.sender until after opening.
cfg := makeTestModelConfig(c, attrs...)
env, err := provider.Open(environs.OpenParams{
Cloud: fakeCloudSpec(),
Config: cfg,
})
c.Assert(err, jc.ErrorIsNil)
// Force an explicit refresh of the access token, so it isn't done
// implicitly during the tests.
*sender = azuretesting.Senders{
discoverAuthSender(),
tokenRefreshSender(),
}
err = azure.ForceTokenRefresh(env)
c.Assert(err, jc.ErrorIsNil)
return env
}
示例2: prepareForBootstrap
func prepareForBootstrap(
c *gc.C,
ctx environs.BootstrapContext,
provider environs.EnvironProvider,
sender *azuretesting.Senders,
attrs ...testing.Attrs,
) environs.Environ {
// Opening the environment should not incur network communication,
// so we don't set s.sender until after opening.
cfg, err := provider.PrepareConfig(environs.PrepareConfigParams{
Config: makeTestModelConfig(c, attrs...),
Cloud: fakeCloudSpec(),
})
c.Assert(err, jc.ErrorIsNil)
env, err := provider.Open(environs.OpenParams{
Cloud: fakeCloudSpec(),
Config: cfg,
})
c.Assert(err, jc.ErrorIsNil)
*sender = azuretesting.Senders{
discoverAuthSender(),
tokenRefreshSender(),
}
err = env.PrepareForBootstrap(ctx)
c.Assert(err, jc.ErrorIsNil)
return env
}
示例3: prepare
func prepare(
ctx environs.BootstrapContext,
p environs.EnvironProvider,
args PrepareParams,
) (environs.Environ, prepareDetails, error) {
var details prepareDetails
cfg, err := config.New(config.NoDefaults, args.ModelConfig)
if err != nil {
return nil, details, errors.Trace(err)
}
cfg, err = p.PrepareConfig(environs.PrepareConfigParams{args.Cloud, cfg})
if err != nil {
return nil, details, errors.Trace(err)
}
env, err := p.Open(environs.OpenParams{
Cloud: args.Cloud,
Config: cfg,
})
if err != nil {
return nil, details, errors.Trace(err)
}
if err := env.PrepareForBootstrap(ctx); err != nil {
return nil, details, errors.Trace(err)
}
// We store the base configuration only; we don't want the
// default attributes, generated secrets/certificates, or
// UUIDs stored in the bootstrap config. Make a copy, so
// we don't disturb the caller's config map.
details.Config = make(map[string]interface{})
for k, v := range args.ModelConfig {
details.Config[k] = v
}
delete(details.Config, config.UUIDKey)
// TODO(axw) change signature of CACert() to not return a bool.
// It's no longer possible to have a controller config without
// a CA certificate.
caCert, ok := args.ControllerConfig.CACert()
if !ok {
return nil, details, errors.New("controller config is missing CA certificate")
}
// We want to store attributes describing how a controller has been configured.
// These do not include the CACert or UUID since they will be replaced with new
// values when/if we need to use this configuration.
details.ControllerConfig = make(controller.Config)
for k, v := range args.ControllerConfig {
if k == controller.CACertKey || k == controller.ControllerUUIDKey {
continue
}
details.ControllerConfig[k] = v
}
for k, v := range args.ControllerConfig {
if k == controller.CACertKey || k == controller.ControllerUUIDKey {
continue
}
details.ControllerConfig[k] = v
}
details.CACert = caCert
details.ControllerUUID = args.ControllerConfig.ControllerUUID()
details.ControllerModelUUID = args.ModelConfig[config.UUIDKey].(string)
details.User = environs.AdminUser
details.Password = args.AdminSecret
details.LastKnownAccess = string(permission.SuperuserAccess)
details.ModelUUID = cfg.UUID()
details.ControllerDetails.Cloud = args.Cloud.Name
details.ControllerDetails.CloudRegion = args.Cloud.Region
details.BootstrapConfig.CloudType = args.Cloud.Type
details.BootstrapConfig.Cloud = args.Cloud.Name
details.BootstrapConfig.CloudRegion = args.Cloud.Region
details.CloudEndpoint = args.Cloud.Endpoint
details.CloudIdentityEndpoint = args.Cloud.IdentityEndpoint
details.CloudStorageEndpoint = args.Cloud.StorageEndpoint
details.Credential = args.CredentialName
return env, details, nil
}