mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Merge pull request #84560 from yue9944882/bugfix/crd-per-version-validation-field-path
Fixes crd per-version validation field path
This commit is contained in:
commit
9c5952e820
@ -100,7 +100,7 @@ func calculateCondition(in *apiextensions.CustomResourceDefinition) *apiextensio
|
|||||||
allErrs = append(allErrs, schema.ValidateStructural(pth, s)...)
|
allErrs = append(allErrs, schema.ValidateStructural(pth, s)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range in.Spec.Versions {
|
for i, v := range in.Spec.Versions {
|
||||||
if v.Schema == nil || v.Schema.OpenAPIV3Schema == nil {
|
if v.Schema == nil || v.Schema.OpenAPIV3Schema == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ func calculateCondition(in *apiextensions.CustomResourceDefinition) *apiextensio
|
|||||||
return cond
|
return cond
|
||||||
}
|
}
|
||||||
|
|
||||||
pth := field.NewPath("spec", "version").Key(v.Name).Child("schema", "openAPIV3Schema")
|
pth := field.NewPath("spec", "versions").Index(i).Child("schema", "openAPIV3Schema")
|
||||||
|
|
||||||
allErrs = append(allErrs, schema.ValidateStructural(pth, s)...)
|
allErrs = append(allErrs, schema.ValidateStructural(pth, s)...)
|
||||||
}
|
}
|
||||||
|
@ -1233,8 +1233,8 @@ properties:
|
|||||||
type: string
|
type: string
|
||||||
`,
|
`,
|
||||||
expectedViolations: []string{
|
expectedViolations: []string{
|
||||||
"spec.version[v1beta1].schema.openAPIV3Schema.properties[a].type: Required value: must not be empty for specified object fields",
|
"spec.versions[0].schema.openAPIV3Schema.properties[a].type: Required value: must not be empty for specified object fields",
|
||||||
"spec.version[v1beta1].schema.openAPIV3Schema.properties[b]: Required value: because it is defined in spec.version[v1beta1].schema.openAPIV3Schema.not.properties[b]",
|
"spec.versions[0].schema.openAPIV3Schema.properties[b]: Required value: because it is defined in spec.versions[0].schema.openAPIV3Schema.not.properties[b]",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1256,10 +1256,10 @@ not:
|
|||||||
d: {}
|
d: {}
|
||||||
`,
|
`,
|
||||||
expectedViolations: []string{
|
expectedViolations: []string{
|
||||||
"spec.version[v1beta1].schema.openAPIV3Schema.properties[a].type: Required value: must not be empty for specified object fields",
|
"spec.versions[0].schema.openAPIV3Schema.properties[a].type: Required value: must not be empty for specified object fields",
|
||||||
"spec.version[v1beta1].schema.openAPIV3Schema.properties[b]: Required value: because it is defined in spec.version[v1beta1].schema.openAPIV3Schema.not.properties[b]",
|
"spec.versions[0].schema.openAPIV3Schema.properties[b]: Required value: because it is defined in spec.versions[0].schema.openAPIV3Schema.not.properties[b]",
|
||||||
"spec.version[v1].schema.openAPIV3Schema.properties[c].type: Required value: must not be empty for specified object fields",
|
"spec.versions[1].schema.openAPIV3Schema.properties[c].type: Required value: must not be empty for specified object fields",
|
||||||
"spec.version[v1].schema.openAPIV3Schema.properties[d]: Required value: because it is defined in spec.version[v1].schema.openAPIV3Schema.not.properties[d]",
|
"spec.versions[1].schema.openAPIV3Schema.properties[d]: Required value: because it is defined in spec.versions[1].schema.openAPIV3Schema.not.properties[d]",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user