feat: support tag upgrades without semver-like tags
This commit is contained in:
parent
e39c6a05be
commit
a12b53abab
@ -166,8 +166,6 @@ var recipeUpgradeCommand = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, service := range compose.Services {
|
for _, service := range compose.Services {
|
||||||
var compatible []tagcmp.Tag
|
|
||||||
|
|
||||||
catlVersions, err := catalogue.VersionsOfService(recipe, service.Name)
|
catlVersions, err := catalogue.VersionsOfService(recipe, service.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
@ -191,15 +189,21 @@ var recipeUpgradeCommand = &cli.Command{
|
|||||||
image = strings.Split(image, "/")[1]
|
image = strings.Split(image, "/")[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
semverLikeTag := true
|
||||||
|
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
|
||||||
|
semverLikeTag = false
|
||||||
|
}
|
||||||
|
|
||||||
tag, err := tagcmp.Parse(img.(reference.NamedTagged).Tag())
|
tag, err := tagcmp.Parse(img.(reference.NamedTagged).Tag())
|
||||||
if err != nil {
|
if err != nil && semverLikeTag {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var compatible []tagcmp.Tag
|
||||||
for _, regVersion := range regVersions {
|
for _, regVersion := range regVersions {
|
||||||
other, err := tagcmp.Parse(regVersion.Name)
|
other, err := tagcmp.Parse(regVersion.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue // skip tags that cannot be parsed
|
||||||
}
|
}
|
||||||
|
|
||||||
if tag.IsCompatible(other) && tag.IsLessThan(other) && !tag.Equals(other) {
|
if tag.IsCompatible(other) && tag.IsLessThan(other) && !tag.Equals(other) {
|
||||||
@ -209,7 +213,7 @@ var recipeUpgradeCommand = &cli.Command{
|
|||||||
|
|
||||||
sort.Sort(tagcmp.ByTag(compatible))
|
sort.Sort(tagcmp.ByTag(compatible))
|
||||||
|
|
||||||
if len(compatible) == 0 {
|
if len(compatible) == 0 && semverLikeTag {
|
||||||
logrus.Info(fmt.Sprintf("No new versions available for '%s', '%s' is the latest", image, tag))
|
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
|
continue // skip on to the next tag and don't update any compose files
|
||||||
}
|
}
|
||||||
@ -227,8 +231,18 @@ var recipeUpgradeCommand = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var upgradeTag string
|
|
||||||
msg := fmt.Sprintf("Which tag would you like to upgrade to? (service: %s, tag: %s)", service.Name, tag)
|
msg := fmt.Sprintf("Which tag would you like to upgrade to? (service: %s, tag: %s)", service.Name, tag)
|
||||||
|
if !tagcmp.IsParsable(img.(reference.NamedTagged).Tag()) {
|
||||||
|
tag := img.(reference.NamedTagged).Tag()
|
||||||
|
logrus.Warning(fmt.Sprintf("Unable to determine versioning semantics of '%s', listing all tags...", tag))
|
||||||
|
msg = fmt.Sprintf("Which tag would you like to upgrade to? (service: %s, tag: %s)", service.Name, tag)
|
||||||
|
compatibleStrings = []string{}
|
||||||
|
for _, regVersion := range regVersions {
|
||||||
|
compatibleStrings = append(compatibleStrings, regVersion.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var upgradeTag string
|
||||||
prompt := &survey.Select{
|
prompt := &survey.Select{
|
||||||
Message: msg,
|
Message: msg,
|
||||||
Options: compatibleStrings,
|
Options: compatibleStrings,
|
||||||
@ -236,6 +250,7 @@ var recipeUpgradeCommand = &cli.Command{
|
|||||||
if err := survey.AskOne(prompt, &upgradeTag); err != nil {
|
if err := survey.AskOne(prompt, &upgradeTag); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.UpdateAppComposeTag(recipe, image, upgradeTag)
|
config.UpdateAppComposeTag(recipe, image, upgradeTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user