fix manifest tag index in manifest.go (#731)

Co-authored-by: Simon Aronsson <simme@arcticbit.se>
This commit is contained in:
nils måsén 2021-01-02 14:32:05 +01:00 committed by GitHub
parent 2fb1f5f7ee
commit 3bbe1bd109
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View file

@ -20,7 +20,7 @@ func BuildManifestURL(container types.Container) (string, error) {
}
host, err := helpers.NormalizeRegistry(normalizedName.String())
img, tag := extractImageAndTag(strings.TrimPrefix(container.ImageName(), host+"/"))
img, tag := ExtractImageAndTag(strings.TrimPrefix(container.ImageName(), host+"/"))
logrus.WithFields(logrus.Fields{
"image": img,
@ -45,15 +45,16 @@ func BuildManifestURL(container types.Container) (string, error) {
return url.String(), nil
}
func extractImageAndTag(imageName string) (string, string) {
// ExtractImageAndTag from a concatenated string
func ExtractImageAndTag(imageName string) (string, string) {
var img string
var tag string
if strings.Contains(imageName, ":") {
parts := strings.Split(imageName, ":")
if len(parts) > 2 {
img = fmt.Sprintf("%s%s", parts[0], parts[1])
tag = parts[3]
img = parts[0]
tag = strings.Join(parts[1:], ":")
} else {
img = parts[0]
tag = parts[1]