diff --git a/kinds/apis/v1beta1/config_types.go b/kinds/apis/v1beta1/config_types.go index 1f75f072b3..d58b9cfdb1 100644 --- a/kinds/apis/v1beta1/config_types.go +++ b/kinds/apis/v1beta1/config_types.go @@ -151,6 +151,15 @@ type Domains struct { ReplicatedRegistryDomain string `json:"replicatedRegistryDomain,omitempty"` } +// +kubebuilder:validation:Enum=aarch64;x86_64 +// Architecture represents a supported CPU architecture identifier. +type Architecture string + +const ( + ArchitectureAarch64 Architecture = "aarch64" + ArchitectureX8664 Architecture = "x86_64" +) + // ConfigSpec defines the desired state of Config type ConfigSpec struct { Version string `json:"version,omitempty"` @@ -160,6 +169,11 @@ type ConfigSpec struct { UnsupportedOverrides UnsupportedOverrides `json:"unsupportedOverrides,omitempty"` Extensions Extensions `json:"extensions,omitempty"` Domains Domains `json:"domains,omitempty"` + // Architecture holds the list of CPU architectures supported by this release. + // If omitted, x86_64 is assumed for backward compatibility. + // +kubebuilder:validation:Optional + // +listType=set + Architecture []Architecture `json:"architecture,omitempty"` } // OverrideForBuiltIn returns the override for the built-in extension with the diff --git a/kinds/apis/v1beta1/zz_generated.deepcopy.go b/kinds/apis/v1beta1/zz_generated.deepcopy.go index 881191eefb..72c7e4983e 100644 --- a/kinds/apis/v1beta1/zz_generated.deepcopy.go +++ b/kinds/apis/v1beta1/zz_generated.deepcopy.go @@ -195,6 +195,11 @@ func (in *ConfigSpec) DeepCopyInto(out *ConfigSpec) { in.UnsupportedOverrides.DeepCopyInto(&out.UnsupportedOverrides) in.Extensions.DeepCopyInto(&out.Extensions) out.Domains = in.Domains + if in.Architecture != nil { + in, out := &in.Architecture, &out.Architecture + *out = make([]Architecture, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigSpec. diff --git a/operator/charts/embedded-cluster-operator/charts/crds/templates/resources.yaml b/operator/charts/embedded-cluster-operator/charts/crds/templates/resources.yaml index edaac28694..6fd64f99b4 100644 --- a/operator/charts/embedded-cluster-operator/charts/crds/templates/resources.yaml +++ b/operator/charts/embedded-cluster-operator/charts/crds/templates/resources.yaml @@ -41,6 +41,19 @@ spec: spec: description: ConfigSpec defines the desired state of Config properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: @@ -362,6 +375,19 @@ spec: config: description: Config holds the configuration used at installation time. properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: diff --git a/operator/config/crd/bases/embeddedcluster.replicated.com_configs.yaml b/operator/config/crd/bases/embeddedcluster.replicated.com_configs.yaml index 355cc2edee..fc2e6d4d5a 100644 --- a/operator/config/crd/bases/embeddedcluster.replicated.com_configs.yaml +++ b/operator/config/crd/bases/embeddedcluster.replicated.com_configs.yaml @@ -39,6 +39,19 @@ spec: spec: description: ConfigSpec defines the desired state of Config properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: diff --git a/operator/config/crd/bases/embeddedcluster.replicated.com_installations.yaml b/operator/config/crd/bases/embeddedcluster.replicated.com_installations.yaml index feda5409c0..509ecbdac0 100644 --- a/operator/config/crd/bases/embeddedcluster.replicated.com_installations.yaml +++ b/operator/config/crd/bases/embeddedcluster.replicated.com_installations.yaml @@ -104,6 +104,19 @@ spec: config: description: Config holds the configuration used at installation time. properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: diff --git a/operator/config/crd/bases/embeddedcluster.replicated.com_kubernetesinstallations.yaml b/operator/config/crd/bases/embeddedcluster.replicated.com_kubernetesinstallations.yaml index e22ee57a85..caa0d652e5 100644 --- a/operator/config/crd/bases/embeddedcluster.replicated.com_kubernetesinstallations.yaml +++ b/operator/config/crd/bases/embeddedcluster.replicated.com_kubernetesinstallations.yaml @@ -63,6 +63,19 @@ spec: config: description: Config holds the configuration used at installation time. properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: diff --git a/operator/schemas/config-embeddedcluster-v1beta1.json b/operator/schemas/config-embeddedcluster-v1beta1.json index 3999d3577a..981e273084 100644 --- a/operator/schemas/config-embeddedcluster-v1beta1.json +++ b/operator/schemas/config-embeddedcluster-v1beta1.json @@ -17,6 +17,19 @@ "description": "ConfigSpec defines the desired state of Config", "type": "object", "properties": { + "architecture": { + "description": "Architecture holds the list of CPU architectures supported by this release.\nIf omitted, x86_64 is assumed for backward compatibility.", + "type": "array", + "items": { + "description": "Architecture represents a supported CPU architecture identifier.", + "type": "string", + "enum": [ + "aarch64", + "x86_64" + ] + }, + "x-kubernetes-list-type": "set" + }, "binaryOverrideUrl": { "type": "string" }, diff --git a/operator/schemas/kubernetesinstallation-embeddedcluster-v1beta1.json b/operator/schemas/kubernetesinstallation-embeddedcluster-v1beta1.json index aa105b43ca..f2bf7bf9f7 100644 --- a/operator/schemas/kubernetesinstallation-embeddedcluster-v1beta1.json +++ b/operator/schemas/kubernetesinstallation-embeddedcluster-v1beta1.json @@ -43,6 +43,19 @@ "description": "Config holds the configuration used at installation time.", "type": "object", "properties": { + "architecture": { + "description": "Architecture holds the list of CPU architectures supported by this release.\nIf omitted, x86_64 is assumed for backward compatibility.", + "type": "array", + "items": { + "description": "Architecture represents a supported CPU architecture identifier.", + "type": "string", + "enum": [ + "aarch64", + "x86_64" + ] + }, + "x-kubernetes-list-type": "set" + }, "binaryOverrideUrl": { "type": "string" }, diff --git a/pkg/crds/resources.yaml b/pkg/crds/resources.yaml index edaac28694..6fd64f99b4 100644 --- a/pkg/crds/resources.yaml +++ b/pkg/crds/resources.yaml @@ -41,6 +41,19 @@ spec: spec: description: ConfigSpec defines the desired state of Config properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: @@ -362,6 +375,19 @@ spec: config: description: Config holds the configuration used at installation time. properties: + architecture: + description: |- + Architecture holds the list of CPU architectures supported by this release. + If omitted, x86_64 is assumed for backward compatibility. + items: + description: Architecture represents a supported CPU architecture + identifier. + enum: + - aarch64 + - x86_64 + type: string + type: array + x-kubernetes-list-type: set binaryOverrideUrl: type: string domains: diff --git a/pkg/lint/validator.go b/pkg/lint/validator.go index a7c8a03b77..e2eb167d3e 100644 --- a/pkg/lint/validator.go +++ b/pkg/lint/validator.go @@ -169,6 +169,32 @@ func (v *Validator) ValidateFile(path string) (*ValidationResult, error) { } } + // Validate architecture values if provided + for i, arch := range config.Spec.Architecture { + val := string(arch) + switch val { + case "aarch64", "x86_64": + // ok + default: + lower := strings.ToLower(val) + var suggestion string + switch lower { + case "arm64": + suggestion = "did you mean aarch64?" + case "amd64": + suggestion = "did you mean x86_64?" + } + msg := fmt.Sprintf("invalid value %q; allowed values are aarch64 and x86_64", string(arch)) + if suggestion != "" { + msg = fmt.Sprintf("%s (%s)", msg, suggestion) + } + result.Errors = append(result.Errors, ValidationError{ + Field: fmt.Sprintf("architecture[%d]", i), + Message: msg, + }) + } + } + return result, nil }