本文整理汇总了Golang中github.com/juju/juju/environs/configstore.EnvironInfo.BootstrapConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang EnvironInfo.BootstrapConfig方法的具体用法?Golang EnvironInfo.BootstrapConfig怎么用?Golang EnvironInfo.BootstrapConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs/configstore.EnvironInfo
的用法示例。
在下文中一共展示了EnvironInfo.BootstrapConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getControllerEnviron
// getControllerEnviron gets the bootstrap information required to destroy the
// environment by first checking the config store, then querying the API if
// the information is not in the store.
func (c *destroyCommandBase) getControllerEnviron(info configstore.EnvironInfo, sysAPI destroyControllerAPI) (_ environs.Environ, err error) {
bootstrapCfg := info.BootstrapConfig()
if bootstrapCfg == nil {
if sysAPI == nil {
return nil, errors.New("unable to get bootstrap information from API")
}
bootstrapCfg, err = sysAPI.EnvironmentConfig()
if params.IsCodeNotImplemented(err) {
// Fallback to the client API. Better to encapsulate the logic for
// old servers than worry about connecting twice.
client, err := c.getClientAPI()
if err != nil {
return nil, errors.Trace(err)
}
defer client.Close()
bootstrapCfg, err = client.EnvironmentGet()
if err != nil {
return nil, errors.Trace(err)
}
} else if err != nil {
return nil, errors.Trace(err)
}
}
cfg, err := config.New(config.NoDefaults, bootstrapCfg)
if err != nil {
return nil, errors.Trace(err)
}
return environs.New(cfg)
}
示例2: getConfig
// getConfig looks for configuration info on the given environment
func getConfig(info configstore.EnvironInfo, envs *environs.Environs, envName string) (*config.Config, error) {
if info != nil && len(info.BootstrapConfig()) > 0 {
cfg, err := config.New(config.NoDefaults, info.BootstrapConfig())
if err != nil {
logger.Warningf("failed to parse bootstrap-config: %v", err)
}
return cfg, err
}
if envs != nil {
cfg, err := envs.Config(envName)
if err != nil && !errors.IsNotFound(err) {
logger.Warningf("failed to get config for environment %q: %v", envName, err)
}
return cfg, err
}
return nil, errors.NotFoundf("environment %q", envName)
}
示例3: getControllerEnviron
// getControllerEnviron gets the bootstrap information required to destroy the
// environment by first checking the config store, then querying the API if
// the information is not in the store.
func (c *destroyCommandBase) getControllerEnviron(info configstore.EnvironInfo, sysAPI destroyControllerAPI) (_ environs.Environ, err error) {
bootstrapCfg := info.BootstrapConfig()
if bootstrapCfg == nil {
if sysAPI == nil {
return nil, errors.New("unable to get bootstrap information from API")
}
bootstrapCfg, err = sysAPI.ModelConfig()
if err != nil {
return nil, errors.Trace(err)
}
}
cfg, err := config.New(config.NoDefaults, bootstrapCfg)
if err != nil {
return nil, errors.Trace(err)
}
return environs.New(cfg)
}