本文整理汇总了Golang中github.com/litl/galaxy/config.Store.UpdateApp方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.UpdateApp方法的具体用法?Golang Store.UpdateApp怎么用?Golang Store.UpdateApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/litl/galaxy/config.Store
的用法示例。
在下文中一共展示了Store.UpdateApp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RuntimeSet
func RuntimeSet(configStore *config.Store, app, env, pool string, options RuntimeOptions) (bool, error) {
cfg, err := configStore.GetApp(app, env)
if err != nil {
return false, err
}
if options.Ps != 0 && options.Ps != cfg.GetProcesses(pool) {
cfg.SetProcesses(pool, options.Ps)
}
if options.Memory != "" && options.Memory != cfg.GetMemory(pool) {
cfg.SetMemory(pool, options.Memory)
}
vhosts := []string{}
vhostsFromEnv := cfg.Env()["VIRTUAL_HOST"]
if vhostsFromEnv != "" {
vhosts = strings.Split(cfg.Env()["VIRTUAL_HOST"], ",")
}
if options.VirtualHost != "" && !utils.StringInSlice(options.VirtualHost, vhosts) {
vhosts = append(vhosts, options.VirtualHost)
cfg.EnvSet("VIRTUAL_HOST", strings.Join(vhosts, ","))
}
if options.Port != "" {
cfg.EnvSet("GALAXY_PORT", options.Port)
}
return configStore.UpdateApp(cfg, env)
}
示例2: RuntimeUnset
func RuntimeUnset(configStore *config.Store, app, env, pool string, options RuntimeOptions) (bool, error) {
cfg, err := configStore.GetApp(app, env)
if err != nil {
return false, err
}
if options.Ps != 0 {
cfg.SetProcesses(pool, -1)
}
if options.Memory != "" {
cfg.SetMemory(pool, "")
}
vhosts := strings.Split(cfg.Env()["VIRTUAL_HOST"], ",")
if options.VirtualHost != "" && utils.StringInSlice(options.VirtualHost, vhosts) {
vhosts = utils.RemoveStringInSlice(options.VirtualHost, vhosts)
cfg.EnvSet("VIRTUAL_HOST", strings.Join(vhosts, ","))
}
if options.Port != "" {
cfg.EnvSet("GALAXY_PORT", "")
}
return configStore.UpdateApp(cfg, env)
}
示例3: AppDeploy
func AppDeploy(configStore *config.Store, serviceRuntime *runtime.ServiceRuntime, app, env, version string) error {
log.Printf("Pulling image %s...", version)
image, err := serviceRuntime.PullImage(version, "")
if image == nil || err != nil {
return fmt.Errorf("unable to pull %s. Has it been released yet?", version)
}
svcCfg, err := configStore.GetApp(app, env)
if err != nil {
return fmt.Errorf("unable to deploy app: %s.", err)
}
if svcCfg == nil {
return fmt.Errorf("app %s does not exist. Create it first.", app)
}
svcCfg.SetVersion(version)
svcCfg.SetVersionID(utils.StripSHA(image.ID))
updated, err := configStore.UpdateApp(svcCfg, env)
if err != nil {
return fmt.Errorf("could not store version: %s", err)
}
if !updated {
return fmt.Errorf("%s NOT deployed.", version)
}
log.Printf("Deployed %s.\n", version)
return nil
}
示例4: ConfigUnset
func ConfigUnset(configStore *config.Store, app, env string, envVars []string) error {
if len(envVars) == 0 {
return fmt.Errorf("no config values specified.")
}
svcCfg, err := configStore.GetApp(app, env)
if err != nil {
return fmt.Errorf("unable to unset config: %s.", err)
}
updated := false
for _, arg := range envVars {
k := strings.ToUpper(strings.TrimSpace(arg))
if k == "ENV" || svcCfg.EnvGet(k) == "" {
log.Warnf("%s cannot be unset.", k)
continue
}
log.Printf("%s\n", k)
svcCfg.EnvSet(strings.ToUpper(arg), "")
updated = true
}
if !updated {
return fmt.Errorf("Configuration NOT changed for %s", app)
}
updated, err = configStore.UpdateApp(svcCfg, env)
if err != nil {
return fmt.Errorf("ERROR: Unable to unset config: %s.", err)
}
if !updated {
return fmt.Errorf("Configuration NOT changed for %s", app)
}
log.Printf("Configuration changed for %s. v%d.\n", app, svcCfg.ID())
return nil
}
示例5: ConfigSet
func ConfigSet(configStore *config.Store, app, env string, envVars []string) error {
if len(envVars) == 0 {
bytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
envVars = strings.Split(string(bytes), "\n")
}
if len(envVars) == 0 {
return fmt.Errorf("no config values specified.")
}
svcCfg, err := configStore.GetApp(app, env)
if err != nil {
return fmt.Errorf("unable to set config: %s.", err)
}
if svcCfg == nil {
svcCfg = configStore.NewAppConfig(app, "")
}
updated := false
for _, arg := range envVars {
if strings.TrimSpace(arg) == "" {
continue
}
if !strings.Contains(arg, "=") {
return fmt.Errorf("bad config variable format: %s", arg)
}
sep := strings.Index(arg, "=")
k := strings.ToUpper(strings.TrimSpace(arg[0:sep]))
v := strings.TrimSpace(arg[sep+1:])
if k == "ENV" {
log.Warnf("%s cannot be updated.", k)
continue
}
log.Printf("%s=%s\n", k, v)
svcCfg.EnvSet(k, v)
updated = true
}
if !updated {
return fmt.Errorf("configuration NOT changed for %s", app)
}
updated, err = configStore.UpdateApp(svcCfg, env)
if err != nil {
return fmt.Errorf("unable to set config: %s.", err)
}
if !updated {
return fmt.Errorf("configuration NOT changed for %s", app)
}
log.Printf("Configuration changed for %s. v%d\n", app, svcCfg.ID())
return nil
}