Skip to content

Commit

Permalink
Rework private registry support (#239)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Oct 25, 2023
1 parent 96b0b64 commit 3f4d007
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 8 deletions.
57 changes: 56 additions & 1 deletion apis/installer/v1alpha1/ace_options_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,61 @@ limitations under the License.

package v1alpha1

import "strings"

func (r RegistrySpec) Configured() bool {
return r.RegistryFQDN != "" || r.Registry != ""
return r.RegistryFQDN != ""
}

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

func (r RegistrySpec) 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 RegistrySpec) GHCRProxy() string {
addr := r.Proxies.GHCR
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}

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

func (r RegistrySpec) AppsCodeRegistryProxy() string {
addr := r.Proxies.AppsCode
if addr == "" {
addr = r.RegistryFQDN
}
addr = strings.TrimSpace(addr)
addr = strings.TrimSuffix(addr, "/")
return addr
}
22 changes: 19 additions & 3 deletions apis/installer/v1alpha1/ace_options_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ type RegistrySpec struct {
//+optional
RegistryFQDN string `json:"registryFQDN"`
//+optional
Registry string `json:"registry"`
//+optional
PreserveOrganization bool `json:"preserveOrganization"`
Proxies RegistryProxies `json:"proxies"`
//+optional
AllowNondistributableArtifacts bool `json:"allowNondistributableArtifacts"`
//+optional
Expand All @@ -83,6 +81,24 @@ type RegistrySpec struct {
ImagePullSecrets []string `json:"imagePullSecrets"`
}

type RegistryProxies struct {
// company/bin:1.23
//+optional
DockerHub string `json:"dockerHub"`
// alpine, nginx etc.
//+optional
DockerLibrary string `json:"dockerLibrary"`
// ghcr.io
//+optional
GHCR string `json:"ghcr"`
// registry.k8s.io
//+optional
Kubernetes string `json:"kubernetes"`
// r.appscode.com
//+optional
AppsCode string `json:"appscode"`
}

type AceOptionsComponentSpec struct {
Enabled bool `json:"enabled"`
//+optional
Expand Down
16 changes: 16 additions & 0 deletions apis/installer/v1alpha1/zz_generated.deepcopy.go

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

22 changes: 18 additions & 4 deletions schema/ace-options/values.openapiv3_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,24 @@ properties:
type: array
insecure:
type: boolean
preserveOrganization:
type: boolean
registry:
type: string
proxies:
properties:
appscode:
description: r.appscode.com
type: string
dockerHub:
description: company/bin:1.23
type: string
dockerLibrary:
description: alpine, nginx etc.
type: string
ghcr:
description: ghcr.io
type: string
kubernetes:
description: registry.k8s.io
type: string
type: object
registryFQDN:
type: string
type: object
Expand Down

0 comments on commit 3f4d007

Please sign in to comment.