Skip to content

Commit

Permalink
Remove registryFQDN
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 31, 2023
1 parent 136a623 commit 20003b3
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 61 deletions.
7 changes: 0 additions & 7 deletions apis/core/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions apis/management/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions apis/meta/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions apis/shared/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ type BootstrapPresets struct {
}

type ImageRegistrySpec struct {
//+optional
RegistryFQDN string `json:"registryFQDN"`
//+optional
Proxies RegistryProxies `json:"proxies"`
}
Expand Down
36 changes: 12 additions & 24 deletions apis/shared/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ func (r ResourceLocator) GraphQuery(oid kmapi.OID) (string, map[string]interface

func (r ImageRegistrySpec) DockerHubProxy() string {
addr := r.Proxies.DockerHub
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
Expand All @@ -108,49 +105,34 @@ func (r ImageRegistrySpec) DockerLibraryProxy() string {
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
Expand All @@ -159,10 +141,6 @@ func (r ImageRegistrySpec) AppsCodeRegistryProxy() string {
const defaultTag = "latest"

func NewRef(spec ImageRegistrySpec, img string) (string, error) {
if spec.RegistryFQDN == "" {
return img, nil
}

ref, err := name.ParseReference(img)
if err != nil {
return "", err
Expand All @@ -174,9 +152,19 @@ func NewRef(spec ImageRegistrySpec, img string) (string, error) {
var result string
_, bin, found := strings.Cut(ref.Repository, "library/")
if found {
result = spec.DockerLibraryProxy() + "/" + bin
addr := spec.DockerLibraryProxy()
if addr != "" {
result = addr + "/" + bin
} else {
result = bin
}
} else {
result = spec.DockerHubProxy() + "/" + ref.Repository
addr := spec.DockerHubProxy()
if addr != "" {
result = addr + "/" + ref.Repository
} else {
addr = ref.Repository

Check failure on line 166 in apis/shared/helpers.go

View workflow job for this annotation

GitHub Actions / k8s (v1.25.8)

ineffectual assignment to addr (ineffassign)
}
}
if ref.Tag != "" && ref.Tag != defaultTag {
result += ":" + ref.Tag
Expand Down
7 changes: 0 additions & 7 deletions apis/shared/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions apis/ui/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20003b3

Please sign in to comment.