feat: -a/--all-tags for listing all tags on recipe upgrade

This commit is contained in:
decentral1se 2022-01-17 21:59:31 +01:00
parent e98f00d354
commit 2f4f288a46
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
2 changed files with 15 additions and 3 deletions

View File

@ -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.

View File

@ -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 {