本文整理汇总了Golang中github.com/juju/core/environs/config.Config.Type方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.Type方法的具体用法?Golang Config.Type怎么用?Golang Config.Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/core/environs/config.Config
的用法示例。
在下文中一共展示了Config.Type方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: validate
// validate calls the state's assigned policy, if non-nil, to obtain
// a ConfigValidator, and calls Validate if a non-nil ConfigValidator is
// returned.
func (st *State) validate(cfg, old *config.Config) (valid *config.Config, err error) {
if st.policy == nil {
return cfg, nil
}
configValidator, err := st.policy.ConfigValidator(cfg.Type())
if errors.IsNotImplemented(err) {
return cfg, nil
} else if err != nil {
return nil, err
}
if configValidator == nil {
return nil, fmt.Errorf("policy returned nil configValidator without an error")
}
return configValidator.Validate(cfg, old)
}
示例2: New
// New returns a new environment based on the provided configuration.
func New(config *config.Config) (Environ, error) {
p, err := Provider(config.Type())
if err != nil {
return nil, err
}
return p.Open(config)
}
示例3: Prepare
// Prepare prepares a new environment based on the provided configuration.
// If the environment is already prepared, it behaves like New.
func Prepare(cfg *config.Config, ctx BootstrapContext, store configstore.Storage) (Environ, error) {
p, err := Provider(cfg.Type())
if err != nil {
return nil, err
}
info, err := store.CreateInfo(cfg.Name())
if err == configstore.ErrEnvironInfoAlreadyExists {
logger.Infof("environment info already exists; using New not Prepare")
info, err := store.ReadInfo(cfg.Name())
if err != nil {
return nil, fmt.Errorf("error reading environment info %q: %v", cfg.Name(), err)
}
if !info.Initialized() {
return nil, fmt.Errorf("found uninitialized environment info for %q; environment preparation probably in progress or interrupted", cfg.Name())
}
if len(info.BootstrapConfig()) == 0 {
return nil, fmt.Errorf("found environment info but no bootstrap config")
}
cfg, err = config.New(config.NoDefaults, info.BootstrapConfig())
if err != nil {
return nil, fmt.Errorf("cannot parse bootstrap config: %v", err)
}
return New(cfg)
}
if err != nil {
return nil, fmt.Errorf("cannot create new info for environment %q: %v", cfg.Name(), err)
}
env, err := prepare(ctx, cfg, info, p)
if err != nil {
if err := info.Destroy(); err != nil {
logger.Warningf("cannot destroy newly created environment info: %v", err)
}
return nil, err
}
info.SetBootstrapConfig(env.Config().AllAttrs())
if err := info.Write(); err != nil {
return nil, fmt.Errorf("cannot create environment info %q: %v", env.Config().Name(), err)
}
return env, nil
}