From ddf405c084d1e6a51815b4934ed55abf5846a954 Mon Sep 17 00:00:00 2001 From: killianmuldoon Date: Tue, 31 Jan 2023 16:46:51 +0000 Subject: [PATCH] Add DefinitionFrom field to ClusterVariable --- api/v1beta1/cluster_types.go | 12 ++++++-- api/v1beta1/zz_generated.openapi.go | 9 +++++- .../crd/bases/cluster.x-k8s.io_clusters.yaml | 30 +++++++++++++++---- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/api/v1beta1/cluster_types.go b/api/v1beta1/cluster_types.go index fa62a1cd4117..9e3095837359 100644 --- a/api/v1beta1/cluster_types.go +++ b/api/v1beta1/cluster_types.go @@ -234,13 +234,19 @@ type MachineHealthCheckTopology struct { MachineHealthCheckClass `json:",inline"` } -// ClusterVariable can be used to customize the Cluster through -// patches. It must comply to the corresponding -// ClusterClassVariable defined in the ClusterClass. +// ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a +// Variable definition in the ClusterClass `status` variables. type ClusterVariable struct { // Name of the variable. Name string `json:"name"` + // DefinitionFrom specifies where the definition of this Variable is from. DefinitionFrom is `inline` when the + // definition is from the ClusterClass `.spec.variables` or the name of a patch defined in the ClusterClass + // `.spec.patches` where the patch is external and provides external variables. + // This field is mandatory if the variable has `DefinitionsConflict: true` in ClusterClass `status.variables[]` + // +optional + DefinitionFrom string `json:"definitionFrom,omitempty"` + // Value of the variable. // Note: the value will be validated against the schema of the corresponding ClusterClassVariable // from the ClusterClass. diff --git a/api/v1beta1/zz_generated.openapi.go b/api/v1beta1/zz_generated.openapi.go index a496c284f5ad..ddf54f5cb6c4 100644 --- a/api/v1beta1/zz_generated.openapi.go +++ b/api/v1beta1/zz_generated.openapi.go @@ -726,7 +726,7 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_ClusterVariable(ref common.Referen return common.OpenAPIDefinition{ Schema: spec.Schema{ SchemaProps: spec.SchemaProps{ - Description: "ClusterVariable can be used to customize the Cluster through patches. It must comply to the corresponding ClusterClassVariable defined in the ClusterClass.", + Description: "ClusterVariable can be used to customize the Cluster through patches. Each ClusterVariable is associated with a Variable definition in the ClusterClass `status` variables.", Type: []string{"object"}, Properties: map[string]spec.Schema{ "name": { @@ -737,6 +737,13 @@ func schema_sigsk8sio_cluster_api_api_v1beta1_ClusterVariable(ref common.Referen Format: "", }, }, + "definitionFrom": { + SchemaProps: spec.SchemaProps{ + Description: "DefinitionFrom specifies where the definition of this Variable is from. DefinitionFrom is `inline` when the definition is from the ClusterClass `.spec.variables` or the name of a patch defined in the ClusterClass `.spec.patches` where the patch is external and provides external variables. This field is mandatory if the variable has `DefinitionsConflict: true` in ClusterClass `status.variables[]`", + Type: []string{"string"}, + Format: "", + }, + }, "value": { SchemaProps: spec.SchemaProps{ Description: "Value of the variable. Note: the value will be validated against the schema of the corresponding ClusterClassVariable from the ClusterClass. Note: We have to use apiextensionsv1.JSON instead of a custom JSON type, because controller-tools has a hard-coded schema for apiextensionsv1.JSON which cannot be produced by another type via controller-tools, i.e. it is not possible to have no type field. Ref: https://github.com/kubernetes-sigs/controller-tools/blob/d0e03a142d0ecdd5491593e941ee1d6b5d91dba6/pkg/crd/known_types.go#L106-L111", diff --git a/config/crd/bases/cluster.x-k8s.io_clusters.yaml b/config/crd/bases/cluster.x-k8s.io_clusters.yaml index 56d2f94bbe4d..518a05e2bfff 100644 --- a/config/crd/bases/cluster.x-k8s.io_clusters.yaml +++ b/config/crd/bases/cluster.x-k8s.io_clusters.yaml @@ -1017,9 +1017,18 @@ spec: defined in the ClusterClass. items: description: ClusterVariable can be used to customize the Cluster - through patches. It must comply to the corresponding ClusterClassVariable - defined in the ClusterClass. + through patches. Each ClusterVariable is associated with a + Variable definition in the ClusterClass `status` variables. properties: + definitionFrom: + description: 'DefinitionFrom specifies where the definition + of this Variable is from. DefinitionFrom is `inline` when + the definition is from the ClusterClass `.spec.variables` + or the name of a patch defined in the ClusterClass `.spec.patches` + where the patch is external and provides external variables. + This field is mandatory if the variable has `DefinitionsConflict: + true` in ClusterClass `status.variables[]`' + type: string name: description: Name of the variable. type: string @@ -1334,10 +1343,21 @@ spec: level variables. items: description: ClusterVariable can be used to customize - the Cluster through patches. It must comply - to the corresponding ClusterClassVariable defined - in the ClusterClass. + the Cluster through patches. Each ClusterVariable + is associated with a Variable definition in + the ClusterClass `status` variables. properties: + definitionFrom: + description: 'DefinitionFrom specifies where + the definition of this Variable is from. + DefinitionFrom is `inline` when the definition + is from the ClusterClass `.spec.variables` + or the name of a patch defined in the ClusterClass + `.spec.patches` where the patch is external + and provides external variables. This field + is mandatory if the variable has `DefinitionsConflict: + true` in ClusterClass `status.variables[]`' + type: string name: description: Name of the variable. type: string