Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Add metadata for top-level and nested variables & deprecate previous metadata field #10778

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ issues:
# should be removed as the referenced deprecated item is removed from the project.
- linters:
- staticcheck
text: "SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|c.TopologyPlan) is deprecated"
text: "SA1019: (bootstrapv1.ClusterStatus|KubeadmConfigSpec.UseExperimentalRetryJoin|scope.Config.Spec.UseExperimentalRetryJoin|DockerMachine.Spec.Bootstrapped|machineStatus.Bootstrapped|c.TopologyPlan|clusterv1.ClusterClassVariableMetadata|(variable|currentDefinition|specVar|newVariableDefinition|statusVarDefinition).Metadata) is deprecated"
# Specific exclude rules for deprecated packages that are still part of the codebase. These
# should be removed as the referenced deprecated packages are removed from the project.
- linters:
Expand Down
28 changes: 28 additions & 0 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ type ClusterClassVariable struct {
// Metadata is the metadata of a variable.
// It can be used to add additional data for higher level tools to
// a ClusterClassVariable.
//
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion. Please use XMetadata in JSONSchemaProps instead.
sbueringer marked this conversation as resolved.
Show resolved Hide resolved
//
// +optional
Metadata ClusterClassVariableMetadata `json:"metadata,omitempty"`

Expand All @@ -406,6 +409,8 @@ type ClusterClassVariable struct {
// ClusterClassVariableMetadata is the metadata of a variable.
// It can be used to add additional data for higher level tools to
// a ClusterClassVariable.
//
// Deprecated: This struct is deprecated and is going to be removed in the next apiVersion.
type ClusterClassVariableMetadata struct {
// Map of string keys and values that can be used to organize and categorize
// (scope and select) variables.
Expand Down Expand Up @@ -569,6 +574,26 @@ type JSONSchemaProps struct {
// +listType=map
// +listMapKey=rule
XValidations []ValidationRule `json:"x-kubernetes-validations,omitempty"`

// XMetadata is the metadata of a variable or a nested field within a variable.
// It can be used to add additional data for higher level tools.
// +optional
XMetadata *VariableSchemaMetadata `json:"x-metadata,omitempty"`
}

// VariableSchemaMetadata is the metadata of a variable or a nested field within a variable.
// It can be used to add additional data for higher level tools.
type VariableSchemaMetadata struct {
// Map of string keys and values that can be used to organize and categorize
// (scope and select) variables.
// +optional
Labels map[string]string `json:"labels,omitempty"`

// Annotations is an unstructured key value map that can be used to store and
// retrieve arbitrary metadata.
// They are not queryable.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`
}

// ValidationRule describes a validation rule written in the CEL expression language.
Expand Down Expand Up @@ -897,6 +922,9 @@ type ClusterClassStatusVariableDefinition struct {
// Metadata is the metadata of a variable.
// It can be used to add additional data for higher level tools to
// a ClusterClassVariable.
//
// Deprecated: This field is deprecated and is going to be removed in the next apiVersion.
//
// +optional
Metadata ClusterClassVariableMetadata `json:"metadata,omitempty"`

Expand Down
34 changes: 34 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

60 changes: 56 additions & 4 deletions api/v1beta1/zz_generated.openapi.go

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

48 changes: 48 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

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

48 changes: 48 additions & 0 deletions internal/controllers/clusterclass/clusterclass_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ func TestClusterClassReconciler_reconcile(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "integer",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand Down Expand Up @@ -408,6 +416,14 @@ func TestReconciler_reconcileVariables(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "integer",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand Down Expand Up @@ -448,6 +464,14 @@ func TestReconciler_reconcileVariables(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "integer",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand Down Expand Up @@ -512,6 +536,14 @@ func TestReconciler_reconcileVariables(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "string",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand All @@ -535,6 +567,14 @@ func TestReconciler_reconcileVariables(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "integer",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand Down Expand Up @@ -565,6 +605,14 @@ func TestReconciler_reconcileVariables(t *testing.T) {
Schema: clusterv1.VariableSchema{
OpenAPIV3Schema: clusterv1.JSONSchemaProps{
Type: "string",
XMetadata: &clusterv1.VariableSchemaMetadata{
Labels: map[string]string{
"some-label": "some-label-value",
},
Annotations: map[string]string{
"some-annotation": "some-annotation-value",
},
},
},
},
Metadata: clusterv1.ClusterClassVariableMetadata{
Expand Down
Loading
Loading