fix: write versions on deploy/upgrade/rollback

See coop-cloud/organising#625
This commit is contained in:
decentral1se 2024-07-17 01:23:26 +02:00
parent cf14731b46
commit 56068362e8
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
3 changed files with 21 additions and 18 deletions

View File

@ -55,13 +55,15 @@ EXAMPLE:
stackName := app.StackName()
specificVersion := c.Args().Get(1)
if specificVersion == "" {
specificVersion = app.Recipe.Version
}
if specificVersion != "" && internal.Chaos {
log.Fatal("cannot use <version> and --chaos together")
}
if specificVersion == "" && app.Recipe.Version != "" {
log.Debugf("retrieved %s as version from env file", app.Recipe.Version)
specificVersion = app.Recipe.Version
}
if err := app.Recipe.Ensure(internal.Chaos, internal.Offline); err != nil {
log.Fatal(err)
}
@ -246,12 +248,15 @@ EXAMPLE:
}
}
if app.Recipe.Version != "" && specificVersion != "" && specificVersion != app.Recipe.Version {
err := app.WriteRecipeVersion(specificVersion)
if err != nil {
app.Recipe.Version = version
if chaosVersion != config.CHAOS_DEFAULT {
app.Recipe.Version = chaosVersion
}
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
log.Fatalf("writing new recipe version in env file: %s", err)
}
}
return nil
},
}

View File

@ -219,12 +219,11 @@ EXAMPLE:
log.Fatal(err)
}
if app.Recipe.Version != "" {
err := app.WriteRecipeVersion(chosenDowngrade)
if err != nil {
app.Recipe.Version = chosenDowngrade
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
log.Fatalf("writing new recipe version in env file: %s", err)
}
}
return nil
},

View File

@ -279,12 +279,11 @@ EXAMPLE:
}
}
if app.Recipe.Version != "" {
err := app.WriteRecipeVersion(chosenUpgrade)
if err != nil {
app.Recipe.Version = chosenUpgrade
log.Debugf("choosing %s as version to save to env file", app.Recipe.Version)
if err := app.WriteRecipeVersion(app.Recipe.Version); err != nil {
log.Fatalf("writing new recipe version in env file: %s", err)
}
}
return nil
},