From 2f4f288a46551cdf57b07717da11b84b9c3cd86c Mon Sep 17 00:00:00 2001 From: cellarspoon Date: Mon, 17 Jan 2022 21:59:31 +0100 Subject: [PATCH] feat: -a/--all-tags for listing all tags on recipe upgrade --- cli/internal/flags.go | 9 +++++++++ cli/recipe/upgrade.go | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cli/internal/flags.go b/cli/internal/flags.go index d18f686e..3d506148 100644 --- a/cli/internal/flags.go +++ b/cli/internal/flags.go @@ -438,6 +438,15 @@ var RegistryPasswordFlag = &cli.StringFlag{ Destination: &RegistryUsername, } +var AllTags bool +var AllTagsFlag = &cli.BoolFlag{ + Name: "all-tags", + Aliases: []string{"a"}, + Value: false, + Usage: "List all tags, not just upgrades", + Destination: &AllTags, +} + // SSHFailMsg is a hopefully helpful SSH failure message var SSHFailMsg = ` Woops, Abra is unable to connect to connect to %s. diff --git a/cli/recipe/upgrade.go b/cli/recipe/upgrade.go index 36c70c6e..e99b3d24 100644 --- a/cli/recipe/upgrade.go +++ b/cli/recipe/upgrade.go @@ -53,6 +53,7 @@ You may invoke this command in "wizard" mode and be prompted for input: internal.PatchFlag, internal.MinorFlag, internal.MajorFlag, + internal.AllTagsFlag, }, Action: func(c *cli.Context) error { recipe := internal.ValidateRecipeWithPrompt(c) @@ -151,7 +152,7 @@ You may invoke this command in "wizard" mode and be prompted for input: sort.Sort(tagcmp.ByTagDesc(compatible)) - if len(compatible) == 0 { + if len(compatible) == 0 && !internal.AllTags { logrus.Info(fmt.Sprintf("no new versions available for %s, %s is the latest", image, tag)) continue // skip on to the next tag and don't update any compose files } @@ -219,9 +220,11 @@ You may invoke this command in "wizard" mode and be prompted for input: } } else { msg := fmt.Sprintf("upgrade to which tag? (service: %s, image: %s, tag: %s)", service.Name, image, tag) - if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) { + if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) || internal.AllTags { tag := img.(reference.NamedTagged).Tag() - logrus.Warning(fmt.Sprintf("unable to determine versioning semantics of %s, listing all tags", tag)) + if !internal.AllTags { + logrus.Warning(fmt.Sprintf("unable to determine versioning semantics of %s, listing all tags", tag)) + } msg = fmt.Sprintf("upgrade to which tag? (service: %s, tag: %s)", service.Name, tag) compatibleStrings = []string{"skip"} for _, regVersion := range regVersions {