You've already forked watchtower
mirror of
https://github.com/containrrr/watchtower.git
synced 2025-07-03 23:30:42 +02:00
clean up scope builder and remove fmt print
This commit is contained in:
@ -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
|
|
||||||
}
|
}
|
||||||
return scopeImage
|
|
||||||
|
if strings.Contains(svc, "docker.io") {
|
||||||
|
return fmt.Sprintf("library/%s", parts[0])
|
||||||
|
}
|
||||||
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChallengeURL creates a URL object based on the image info
|
// GetChallengeURL creates a URL object based on the image info
|
||||||
|
Reference in New Issue
Block a user