From a71b0709218782237e2c58c07d89fc16ca852389 Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Sun, 2 Jan 2022 15:46:35 +0100 Subject: [PATCH] feat: support skipping upgrades --- cli/recipe/upgrade.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cli/recipe/upgrade.go b/cli/recipe/upgrade.go index 908d5235..46ab6d7d 100644 --- a/cli/recipe/upgrade.go +++ b/cli/recipe/upgrade.go @@ -38,6 +38,10 @@ Some image tags cannot be parsed because they do not follow some sort of semver-like convention. In this case, all possible tags will be listed and it is up to the end-user to decide. +The command is interactive and will show a select input which allows you to +make a seclection. Use the "?" key to see more help on navigating this +interface. + You may invoke this command in "wizard" mode and be prompted for input: abra recipe upgrade @@ -154,7 +158,7 @@ You may invoke this command in "wizard" mode and be prompted for input: logrus.Fatal(err) } - var compatibleStrings []string + compatibleStrings := []string{"skip"} for _, compat := range compatible { skip := false for _, catlVersion := range catlVersions { @@ -224,6 +228,8 @@ You may invoke this command in "wizard" mode and be prompted for input: prompt := &survey.Select{ Message: msg, + Help: "enter / return to confirm, choose 'skip' to not upgrade this tag, vim mode is enabled", + VimMode: true, Options: compatibleStrings, } if err := survey.AskOne(prompt, &upgradeTag); err != nil { @@ -231,10 +237,14 @@ You may invoke this command in "wizard" mode and be prompted for input: } } } - if err := recipe.UpdateTag(image, upgradeTag); err != nil { - logrus.Fatal(err) + if upgradeTag != "skip" { + if err := recipe.UpdateTag(image, upgradeTag); err != nil { + logrus.Fatal(err) + } + logrus.Infof("tag upgraded from %s to %s for %s", tag.String(), upgradeTag, image) + } else { + logrus.Warnf("not upgrading %s, skipping as requested", image) } - logrus.Infof("tag upgraded from %s to %s for %s", tag.String(), upgradeTag, image) } return nil