Compare commits

...

3 Commits

Author SHA1 Message Date
Roxie Gibson d5b893d9de
style: rm unneeded type assertions
continuous-integration/drone/push Build is passing Details
2021-08-12 14:56:06 +01:00
Roxie Gibson b143b544b6
fix: err not being checked & unneeded type assert 2021-08-12 14:53:42 +01:00
Roxie Gibson 6df08df509
style(tagcmp): simplify returns 2021-08-12 14:44:49 +01:00
4 changed files with 9 additions and 15 deletions

View File

@ -188,7 +188,7 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
logrus.Fatal(err) logrus.Fatal(err)
} }
image := reference.Path(img.(reference.Named)) image := reference.Path(img)
regVersions, err := client.GetRegistryTags(image) regVersions, err := client.GetRegistryTags(image)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
@ -263,7 +263,9 @@ This is step 1 of upgrading a recipe. Step 2 is running "abra recipe sync
logrus.Fatal(err) logrus.Fatal(err)
} }
config.UpdateAppComposeTag(recipe, image, upgradeTag) if err := config.UpdateAppComposeTag(recipe, image, upgradeTag); err != nil {
logrus.Fatal(err)
}
} }
return nil return nil

View File

@ -34,7 +34,7 @@ func GetRegistryTags(image string) (RawTags, error) {
// getRegv2Token retrieves a registry v2 authentication token. // getRegv2Token retrieves a registry v2 authentication token.
func getRegv2Token(image reference.Named) (string, error) { func getRegv2Token(image reference.Named) (string, error) {
img := reference.Path(image.(reference.Named)) img := reference.Path(image)
authTokenURL := fmt.Sprintf("https://auth.docker.io/token?service=registry.docker.io&scope=repository:%s:pull", img) authTokenURL := fmt.Sprintf("https://auth.docker.io/token?service=registry.docker.io&scope=repository:%s:pull", img)
req, err := http.NewRequest("GET", authTokenURL, nil) req, err := http.NewRequest("GET", authTokenURL, nil)
if err != nil { if err != nil {
@ -75,7 +75,7 @@ func getRegv2Token(image reference.Named) (string, error) {
// GetTagDigest retrieves an image digest from a v2 registry // GetTagDigest retrieves an image digest from a v2 registry
func GetTagDigest(image reference.Named) (string, error) { func GetTagDigest(image reference.Named) (string, error) {
img := reference.Path(image.(reference.Named)) img := reference.Path(image)
tag := image.(reference.NamedTagged).Tag() tag := image.(reference.NamedTagged).Tag()
manifestURL := fmt.Sprintf("https://index.docker.io/v2/%s/manifests/%s", img, tag) manifestURL := fmt.Sprintf("https://index.docker.io/v2/%s/manifests/%s", img, tag)

View File

@ -268,7 +268,7 @@ func UpdateAppComposeTag(recipe, image, tag string) error {
logrus.Fatal(err) logrus.Fatal(err)
} }
composeImage := reference.Path(img.(reference.Named)) composeImage := reference.Path(img)
if strings.Contains(composeImage, "library") { if strings.Contains(composeImage, "library") {
// ParseNormalizedNamed prepends 'library' to images like nginx:<tag>, // ParseNormalizedNamed prepends 'library' to images like nginx:<tag>,
// postgres:<tag>, i.e. images which do not have a username in the // postgres:<tag>, i.e. images which do not have a username in the

View File

@ -74,11 +74,7 @@ func (t Tag) IsGreaterThan(tag Tag) bool {
// take into account here, shorter is bigger (i.e. 2.1 < 2.1.1 == false, 2 < // take into account here, shorter is bigger (i.e. 2.1 < 2.1.1 == false, 2 <
// 2.1 == false). // 2.1 == false).
func (t Tag) IsLessThan(tag Tag) bool { func (t Tag) IsLessThan(tag Tag) bool {
if t.IsGreaterThan(tag) { return !t.IsGreaterThan(tag)
return false
}
return true
} }
// Equals tests Tag equality // Equals tests Tag equality
@ -106,11 +102,7 @@ func (t Tag) Equals(tag Tag) bool {
p1, _ := strconv.Atoi(t.Patch) p1, _ := strconv.Atoi(t.Patch)
p2, _ := strconv.Atoi(tag.Patch) p2, _ := strconv.Atoi(tag.Patch)
if p1 != p2 { return p1 == p2
return false
}
return true
} }
// String formats a Tag correctly in string representation // String formats a Tag correctly in string representation