diff --git a/apis/installer/v1alpha1/ace_options_helpers.go b/apis/installer/v1alpha1/ace_options_helpers.go index 5999a3646..5fef110aa 100644 --- a/apis/installer/v1alpha1/ace_options_helpers.go +++ b/apis/installer/v1alpha1/ace_options_helpers.go @@ -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 } diff --git a/apis/installer/v1alpha1/ace_options_types.go b/apis/installer/v1alpha1/ace_options_types.go index e11fdde30..e9ca3c3bc 100644 --- a/apis/installer/v1alpha1/ace_options_types.go +++ b/apis/installer/v1alpha1/ace_options_types.go @@ -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 @@ -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 diff --git a/apis/installer/v1alpha1/zz_generated.deepcopy.go b/apis/installer/v1alpha1/zz_generated.deepcopy.go index a7a1534e1..a7f80b938 100644 --- a/apis/installer/v1alpha1/zz_generated.deepcopy.go +++ b/apis/installer/v1alpha1/zz_generated.deepcopy.go @@ -6147,9 +6147,25 @@ func (in *RegistryInfo) DeepCopy() *RegistryInfo { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RegistryProxies) DeepCopyInto(out *RegistryProxies) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RegistryProxies. +func (in *RegistryProxies) DeepCopy() *RegistryProxies { + if in == nil { + return nil + } + out := new(RegistryProxies) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RegistrySpec) DeepCopyInto(out *RegistrySpec) { *out = *in + out.Proxies = in.Proxies if in.ImagePullSecrets != nil { in, out := &in.ImagePullSecrets, &out.ImagePullSecrets *out = make([]string, len(*in)) diff --git a/schema/ace-options/values.openapiv3_schema.yaml b/schema/ace-options/values.openapiv3_schema.yaml index fd9de398b..222c78f0c 100644 --- a/schema/ace-options/values.openapiv3_schema.yaml +++ b/schema/ace-options/values.openapiv3_schema.yaml @@ -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