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

View File

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

View File

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