Skip to content

Commit

Permalink
Add ImageRegistrySpec helpers
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 29, 2023
1 parent 4a3745f commit bcb43a7
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions apis/shared/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,66 @@ func (r ResourceLocator) GraphQuery(oid kmapi.OID) (string, map[string]interface
}
return "", nil, fmt.Errorf("unknown query type %+v, oid %s", r, oid)
}

func (r ImageRegistrySpec) DockerHubProxy() string {
addr := r.Proxies.DockerHub
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

func (r ImageRegistrySpec) DockerLibraryProxy() string {
addr := r.Proxies.DockerLibrary
if addr == "" {
addr = r.Proxies.DockerHub
}
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

func (r ImageRegistrySpec) GHCRProxy() string {
addr := r.Proxies.GHCR
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

func (r ImageRegistrySpec) QuayProxy() string {
addr := r.Proxies.Quay
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

func (r ImageRegistrySpec) KubernetesRegistryProxy() string {
addr := r.Proxies.Kubernetes
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

func (r ImageRegistrySpec) AppsCodeRegistryProxy() string {
addr := r.Proxies.AppsCode
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

0 comments on commit bcb43a7

Please sign in to comment.