Skip to content

Commit

Permalink
Add metadata for top-level and nested variables
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer committed Jun 18, 2024
1 parent dc757d2 commit b74a31a
Show file tree
Hide file tree
Showing 9 changed files with 508 additions and 4 deletions.
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.
//
// +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 @@ -551,6 +556,26 @@ type JSONSchemaProps struct {
// NOTE: Can be set for all types.
// +optional
Default *apiextensionsv1.JSON `json:"default,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"`
}

// ClusterClassPatch defines a patch which is applied to customize the referenced templates.
Expand Down Expand Up @@ -769,6 +794,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
30 changes: 30 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.

61 changes: 57 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{

Check failure on line 127 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)

Check failure on line 127 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)
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{

Check failure on line 429 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)

Check failure on line 429 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)
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{

Check failure on line 477 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)

Check failure on line 477 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)
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{

Check failure on line 549 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)

Check failure on line 549 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)
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{

Check failure on line 580 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)

Check failure on line 580 in internal/controllers/clusterclass/clusterclass_controller_test.go

View workflow job for this annotation

GitHub Actions / lint

SA1019: clusterv1.ClusterClassVariableMetadata is deprecated: This struct is deprecated and is going to be removed in the next apiVersion. (staticcheck)
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

0 comments on commit b74a31a

Please sign in to comment.