mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Fix field paths
This commit is contained in:
parent
45742d1d9a
commit
61d6026d23
@ -808,13 +808,13 @@ func ValidateCustomResourceSelectableFields(selectableFields []apiextensions.Sel
|
||||
continue
|
||||
}
|
||||
if path.Root().String() == "metadata" {
|
||||
allErrs = append(allErrs, field.Invalid(indexFldPath, selectableField.JSONPath, "must not point to fields in metadata"))
|
||||
allErrs = append(allErrs, field.Invalid(indexFldPath.Child("jsonPath"), selectableField.JSONPath, "must not point to fields in metadata"))
|
||||
}
|
||||
if !allowedSelectableFieldSchema(foundSchema) {
|
||||
allErrs = append(allErrs, field.Invalid(indexFldPath, selectableField.JSONPath, "must point to a field of type string, boolean or integer. Enum string fields and strings with formats are allowed."))
|
||||
allErrs = append(allErrs, field.Invalid(indexFldPath.Child("jsonPath"), selectableField.JSONPath, "must point to a field of type string, boolean or integer. Enum string fields and strings with formats are allowed."))
|
||||
}
|
||||
if uniqueSelectableFields.Has(path.String()) {
|
||||
allErrs = append(allErrs, field.Duplicate(indexFldPath, selectableField.JSONPath))
|
||||
allErrs = append(allErrs, field.Duplicate(indexFldPath.Child("jsonPath"), selectableField.JSONPath))
|
||||
} else {
|
||||
uniqueSelectableFields.Insert(path.String())
|
||||
}
|
||||
|
@ -4429,9 +4429,9 @@ func TestSelectableFields(t *testing.T) {
|
||||
},
|
||||
},
|
||||
errors: []validationMatch{
|
||||
invalid("spec", "versions[0]", "selectableFields[1]"),
|
||||
invalid("spec", "versions[1]", "selectableFields[0]"),
|
||||
invalid("spec", "versions[1]", "selectableFields[2]"),
|
||||
invalid("spec", "versions[0]", "selectableFields[1].jsonPath"),
|
||||
invalid("spec", "versions[1]", "selectableFields[0].jsonPath"),
|
||||
invalid("spec", "versions[1]", "selectableFields[2].jsonPath"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -4474,7 +4474,7 @@ func TestSelectableFields(t *testing.T) {
|
||||
},
|
||||
},
|
||||
errors: []validationMatch{
|
||||
invalid("spec", "selectableFields[1]"),
|
||||
invalid("spec", "selectableFields[1].jsonPath"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -4520,8 +4520,8 @@ func TestSelectableFields(t *testing.T) {
|
||||
},
|
||||
},
|
||||
errors: []validationMatch{
|
||||
invalid("spec", "versions[0]", "selectableFields[1]"),
|
||||
invalid("spec", "versions[1]", "selectableFields[0]"),
|
||||
invalid("spec", "versions[0]", "selectableFields[1].jsonPath"),
|
||||
invalid("spec", "versions[1]", "selectableFields[0].jsonPath"),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -4567,8 +4567,8 @@ func TestSelectableFields(t *testing.T) {
|
||||
},
|
||||
},
|
||||
errors: []validationMatch{
|
||||
duplicate("spec", "versions[0]", "selectableFields[1]"),
|
||||
duplicate("spec", "versions[1]", "selectableFields[1]"),
|
||||
duplicate("spec", "versions[0]", "selectableFields[1].jsonPath"),
|
||||
duplicate("spec", "versions[1]", "selectableFields[1].jsonPath"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user