This repository was archived by the owner on Apr 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ require (
6363 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
6464 golang.org/x/net v0.19.0 // indirect
6565 golang.org/x/oauth2 v0.14.0 // indirect
66+ golang.org/x/sync v0.5.0 // indirect
6667 golang.org/x/sys v0.16.0 // indirect
6768 golang.org/x/term v0.15.0 // indirect
6869 golang.org/x/text v0.14.0 // indirect
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
1414 clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
1515)
1616
17- // convertToAPIExtensionsJSONSchemaProps converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp.
17+ // ConvertToAPIExtensionsJSONSchemaProps converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp.
1818// NOTE: This is used whenever we want to use one of the upstream libraries, as they use apiextensions.JSONSchemaProp.
1919// NOTE: If new fields are added to clusterv1.JSONSchemaProps (e.g. to support complex types), the corresponding
2020// schema validation must be added to validateRootSchema too.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010
1111 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
1212 structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
13+ "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/defaulting"
1314 structuralpruning "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning"
1415 "k8s.io/apiextensions-apiserver/pkg/apiserver/validation"
1516 "k8s.io/apimachinery/pkg/util/validation/field"
@@ -62,6 +63,18 @@ func ValidateClusterVariable(
6263 )}
6364 }
6465
66+ s , err := structuralschema .NewStructural (apiExtensionsSchema )
67+ if err != nil {
68+ return field.ErrorList {field .InternalError (fldPath ,
69+ fmt .Errorf (
70+ "failed to create structural schema for variable %q; ClusterClass should be checked: %v" ,
71+ value .Name ,
72+ err ,
73+ ),
74+ )}
75+ }
76+ defaulting .Default (variableValue , s )
77+
6578 // Validate variable against the schema.
6679 // NOTE: We're reusing a library func used in CRD validation.
6780 if err := validation .ValidateCustomResource (fldPath , variableValue , validator ); err != nil {
You can’t perform that action at this time.
0 commit comments