Fix #444 #329

Merged
decentral1se merged 4 commits from partial-fix-444 into main 2023-07-25 15:04:22 +00:00
3 changed files with 12 additions and 13 deletions

View File

@ -124,17 +124,15 @@ recipes.
} }
} }
availableDowngrades = internal.ReverseStringList(availableDowngrades)
var chosenDowngrade string var chosenDowngrade string
if !internal.Chaos { if len(availableDowngrades) > 0 && !internal.Chaos {
if internal.Force || internal.NoInput { if internal.Force || internal.NoInput {
chosenDowngrade = availableDowngrades[0] chosenDowngrade = availableDowngrades[len(availableDowngrades)-1]
logrus.Debugf("choosing %s as version to downgrade to (--force)", chosenDowngrade) logrus.Debugf("choosing %s as version to downgrade to (--force)", chosenDowngrade)
} else { } else {
prompt := &survey.Select{ prompt := &survey.Select{
Message: fmt.Sprintf("Please select a downgrade (current version: %s):", deployedVersion), 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 { if err := survey.AskOne(prompt, &chosenDowngrade); err != nil {
return err return err
@ -186,11 +184,9 @@ recipes.
config.SetChaosVersionLabel(compose, stackName, chosenDowngrade) config.SetChaosVersionLabel(compose, stackName, chosenDowngrade)
config.SetUpdateLabel(compose, stackName, app.Env) config.SetUpdateLabel(compose, stackName, app.Env)
if !internal.Force {
if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil { if err := internal.NewVersionOverview(app, deployedVersion, chosenDowngrade, ""); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
}
if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil { if err := stack.RunDeploy(cl, deployOpts, compose, stackName, internal.DontWaitConverge); err != nil {
logrus.Fatal(err) logrus.Fatal(err)

View File

@ -127,8 +127,6 @@ recipes.
} }
} }
availableUpgrades = internal.ReverseStringList(availableUpgrades)
var chosenUpgrade string var chosenUpgrade string
if len(availableUpgrades) > 0 && !internal.Chaos { if len(availableUpgrades) > 0 && !internal.Chaos {
if internal.Force || internal.NoInput { if internal.Force || internal.NoInput {
@ -137,7 +135,7 @@ recipes.
} else { } else {
prompt := &survey.Select{ prompt := &survey.Select{
Message: fmt.Sprintf("Please select an upgrade (current version: %s):", deployedVersion), 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 { if err := survey.AskOne(prompt, &chosenUpgrade); err != nil {
return err 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 // 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 // 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 // when we obviously will forget to write release notes before publishing

View File

@ -317,7 +317,7 @@ func EnsureVersion(recipeName, version string) error {
logrus.Debugf("read %s as tags for recipe %s", strings.Join(parsedTags, ", "), recipeName) logrus.Debugf("read %s as tags for recipe %s", strings.Join(parsedTags, ", "), recipeName)
if tagRef.String() == "" { 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() worktree, err := repo.Worktree()