本文整理匯總了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)
}