clean up scope builder and remove fmt print

pull/716/head v1.1.2
Simon Aronsson 4 years ago
parent cf6a71de81
commit 89119515af
No known key found for this signature in database
GPG Key ID: 8DA57A5FD341605B

@ -153,26 +153,25 @@ func GetAuthURL(challenge string, img string) (*url.URL, error) {
// GetScopeFromImageName normalizes an image name for use as scope during auth and head requests // GetScopeFromImageName normalizes an image name for use as scope during auth and head requests
func GetScopeFromImageName(img, svc string) string { func GetScopeFromImageName(img, svc string) string {
parts := strings.Split(img, "/") parts := strings.Split(img, "/")
scopeImage := ""
if len(parts) > 2 { if len(parts) > 2 {
if strings.Contains(svc, "docker.io") { if strings.Contains(svc, "docker.io") {
fmt.Printf("Identified dockerhub image") return fmt.Sprintf("%s/%s", parts[1], strings.Join(parts[2:], "/"))
scopeImage = fmt.Sprintf("%s/%s", parts[1], strings.Join(parts[2:], "/"))
} else {
scopeImage = strings.Join(parts, "/")
} }
} else if len(parts) == 2 { return strings.Join(parts, "/")
}
if len(parts) == 2 {
if strings.Contains(parts[0], "docker.io") { if strings.Contains(parts[0], "docker.io") {
scopeImage = fmt.Sprintf("library/%s", parts[1]) return fmt.Sprintf("library/%s", parts[1])
} else {
scopeImage = strings.Replace(img, svc+"/", "", 1)
} }
} else if strings.Contains(svc, "docker.io") { return strings.Replace(img, svc+"/", "", 1)
scopeImage = fmt.Sprintf("library/%s", parts[0]) }
} else {
scopeImage = img if strings.Contains(svc, "docker.io") {
return fmt.Sprintf("library/%s", parts[0])
} }
return scopeImage return img
} }
// GetChallengeURL creates a URL object based on the image info // GetChallengeURL creates a URL object based on the image info

Loading…
Cancel
Save