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