diff --git a/cli/app/deploy.go b/cli/app/deploy.go index 6b84b720..7a17fb8b 100644 --- a/cli/app/deploy.go +++ b/cli/app/deploy.go @@ -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 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 { - log.Fatalf("writing new recipe version in env file: %s", err) - } + 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 }, } diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 5c526f7f..5e41f9c9 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -219,11 +219,10 @@ EXAMPLE: log.Fatal(err) } - if app.Recipe.Version != "" { - err := app.WriteRecipeVersion(chosenDowngrade) - if err != nil { - log.Fatalf("writing new recipe version in env file: %s", err) - } + 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 diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 3e6e9d15..2e4ff78f 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -279,11 +279,10 @@ EXAMPLE: } } - if app.Recipe.Version != "" { - err := app.WriteRecipeVersion(chosenUpgrade) - if err != nil { - log.Fatalf("writing new recipe version in env file: %s", err) - } + 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