mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
Merge pull request #64766 from nikhita/allow-description-at-root
Automatic merge from submit-queue (batch tested with PRs 64276, 64094, 64719, 64766, 64750). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. apiextensions: allow Description at root with status subresource Allows `Description` at the root of the schema when the status subresource is enabled. **Release note**: I'll update the original PR, which allowed `Required`, to de-duplicate the release notes. ```release-note NONE ``` /assign sttts
This commit is contained in:
commit
c279578862
@ -291,7 +291,7 @@ func ValidateCustomResourceDefinitionValidation(customResourceValidation *apiext
|
||||
}
|
||||
|
||||
if schema := customResourceValidation.OpenAPIV3Schema; schema != nil {
|
||||
// if subresources are enabled, only "properties" and "required" is allowed inside the root schema
|
||||
// if subresources are enabled, only "properties", "required" and "description" are allowed inside the root schema
|
||||
if utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) && statusSubresourceEnabled {
|
||||
v := reflect.ValueOf(schema).Elem()
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
@ -300,8 +300,8 @@ func ValidateCustomResourceDefinitionValidation(customResourceValidation *apiext
|
||||
continue
|
||||
}
|
||||
|
||||
if name := v.Type().Field(i).Name; name != "Properties" && name != "Required" {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("openAPIV3Schema"), *schema, fmt.Sprintf(`must only have "properties" or "required" at the root if the status subresource is enabled`)))
|
||||
if name := v.Type().Field(i).Name; name != "Properties" && name != "Required" && name != "Description" {
|
||||
allErrs = append(allErrs, field.Invalid(fldPath.Child("openAPIV3Schema"), *schema, fmt.Sprintf(`must only have "properties", "required" or "description" at the root if the status subresource is enabled`)))
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -849,14 +849,15 @@ func TestValidateCustomResourceDefinitionValidation(t *testing.T) {
|
||||
wantError: true,
|
||||
},
|
||||
{
|
||||
name: "properties and required with status",
|
||||
name: "properties, required and description with status",
|
||||
input: apiextensions.CustomResourceValidation{
|
||||
OpenAPIV3Schema: &apiextensions.JSONSchemaProps{
|
||||
Properties: map[string]apiextensions.JSONSchemaProps{
|
||||
"spec": {},
|
||||
"status": {},
|
||||
},
|
||||
Required: []string{"spec", "status"},
|
||||
Required: []string{"spec", "status"},
|
||||
Description: "This is a description",
|
||||
},
|
||||
},
|
||||
statusEnabled: true,
|
||||
|
@ -359,7 +359,8 @@ func TestValidationSchema(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Required: []string{"spec"},
|
||||
Required: []string{"spec"},
|
||||
Description: "This is a description at the root of the schema",
|
||||
}
|
||||
noxuDefinition, err = testserver.CreateNewCustomResourceDefinition(noxuDefinition, apiExtensionClient, dynamicClient)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user