This repository was archived by the owner on Apr 11, 2024. It is now read-only.
File tree 3 files changed +15
-1
lines changed
3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ require (
63
63
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
64
64
golang.org/x/net v0.19.0 // indirect
65
65
golang.org/x/oauth2 v0.14.0 // indirect
66
+ golang.org/x/sync v0.5.0 // indirect
66
67
golang.org/x/sys v0.16.0 // indirect
67
68
golang.org/x/term v0.15.0 // indirect
68
69
golang.org/x/text v0.14.0 // indirect
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import (
14
14
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
15
15
)
16
16
17
- // convertToAPIExtensionsJSONSchemaProps converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp.
17
+ // ConvertToAPIExtensionsJSONSchemaProps converts a clusterv1.JSONSchemaProps to apiextensions.JSONSchemaProp.
18
18
// NOTE: This is used whenever we want to use one of the upstream libraries, as they use apiextensions.JSONSchemaProp.
19
19
// NOTE: If new fields are added to clusterv1.JSONSchemaProps (e.g. to support complex types), the corresponding
20
20
// schema validation must be added to validateRootSchema too.
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
11
11
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
12
12
structuralschema "k8s.io/apiextensions-apiserver/pkg/apiserver/schema"
13
+ "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/defaulting"
13
14
structuralpruning "k8s.io/apiextensions-apiserver/pkg/apiserver/schema/pruning"
14
15
"k8s.io/apiextensions-apiserver/pkg/apiserver/validation"
15
16
"k8s.io/apimachinery/pkg/util/validation/field"
@@ -62,6 +63,18 @@ func ValidateClusterVariable(
62
63
)}
63
64
}
64
65
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
+
65
78
// Validate variable against the schema.
66
79
// NOTE: We're reusing a library func used in CRD validation.
67
80
if err := validation .ValidateCustomResource (fldPath , variableValue , validator ); err != nil {
You can’t perform that action at this time.
0 commit comments