-
Notifications
You must be signed in to change notification settings - Fork 0
/
which_registry.go
57 lines (47 loc) · 947 Bytes
/
which_registry.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package which_registry
import (
"strings"
)
func parseRepo(r string) string {
return strings.Split(r, "/")[0]
}
func Which(image string) (Registry, error) {
var r Registry
repo, _, _, err := ParseImageName(image)
if err != nil {
return r, err
}
domain := parseRepo(repo)
if isDockerHub(domain) {
return DOCKER_HUB, nil
} else if isECRPublic(domain) {
return ECR_PUBLIC, nil
} else if isQuayIO(domain) {
return QUAY_IO, nil
}
isECRp, err := isECRPrivate(domain)
if err != nil {
return r, err
}
if isECRp {
return ECR_PRIVATE, nil
}
isGAR, err := isGoogleArtifactRegistry(domain)
if err != nil {
return r, err
}
if isGAR {
return GOOGLE_ARTIFACT_REGISTRY, nil
}
isGCR, err := isGoogleContainerRegistry(domain)
if err != nil {
return r, err
}
if isGCR {
return GOOGLE_CONTAINER_REGISTRY, nil
}
if isGitHubContainerRegistry(domain) {
return GITHUB_CONTAINER_REGISTRY, nil
}
return r, nil
}