本文整理汇总了Golang中github.com/wallyworld/core/environs/configstore.Storage.CreateInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.CreateInfo方法的具体用法?Golang Storage.CreateInfo怎么用?Golang Storage.CreateInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wallyworld/core/environs/configstore.Storage
的用法示例。
在下文中一共展示了Storage.CreateInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}