diff --git a/cli/app/rollback.go b/cli/app/rollback.go index 5b986cbf..756d4729 100644 --- a/cli/app/rollback.go +++ b/cli/app/rollback.go @@ -124,17 +124,15 @@ recipes. } } - availableDowngrades = internal.ReverseStringList(availableDowngrades) - var chosenDowngrade string - if !internal.Chaos { + if len(availableDowngrades) > 0 && !internal.Chaos { if internal.Force || internal.NoInput { - chosenDowngrade = availableDowngrades[0] + chosenDowngrade = availableDowngrades[len(availableDowngrades)-1] logrus.Debugf("choosing %s as version to downgrade to (--force)", chosenDowngrade) } else { prompt := &survey.Select{ Message: fmt.Sprintf("Please select a downgrade (current version: %s):", deployedVersion), - Options: availableDowngrades, + Options: internal.ReverseStringList(availableDowngrades), } if err := survey.AskOne(prompt, &chosenDowngrade); err != nil { return err @@ -186,10 +184,8 @@ recipes. config.SetChaosVersionLabel(compose, stackName, chosenDowngrade) config.SetUpdateLabel(compose, stackName, app.Env) - if !internal.Force { - if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { - logrus.Fatal(err) - } + if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { + logrus.Fatal(err) } if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil { diff --git a/cli/app/upgrade.go b/cli/app/upgrade.go index 197a9ab6..3c39baf7 100644 --- a/cli/app/upgrade.go +++ b/cli/app/upgrade.go @@ -127,8 +127,6 @@ recipes. } } - availableUpgrades = internal.ReverseStringList(availableUpgrades) - var chosenUpgrade string if len(availableUpgrades) > 0 && !internal.Chaos { if internal.Force || internal.NoInput { @@ -137,7 +135,7 @@ recipes. } else { prompt := &survey.Select{ Message: fmt.Sprintf("Please select an upgrade (current version: %s):", deployedVersion), - Options: availableUpgrades, + Options: internal.ReverseStringList(availableUpgrades), } if err := survey.AskOne(prompt, &chosenUpgrade); err != nil { return err @@ -145,6 +143,11 @@ recipes. } } + if internal.Force && chosenUpgrade == "" { + logrus.Warnf("%s is already upgraded to latest but continuing (--force/--chaos)", app.Name) + chosenUpgrade = deployedVersion + } + // if release notes written after git tag published, read them before we // check out the tag and then they'll appear to be missing. this covers // when we obviously will forget to write release notes before publishing diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 0c63725c..14661215 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -317,7 +317,7 @@ func EnsureVersion(recipeName, version string) error { logrus.Debugf("read %s as tags for recipe %s", strings.Join(parsedTags, ", "), recipeName) if tagRef.String() == "" { - return fmt.Errorf("no published release discovered for %s", recipeName) + return fmt.Errorf("the local copy of %s doesn't seem to have version %s available?", recipeName, version) } worktree, err := repo.Worktree()