mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Merge pull request #127303 from omerap12/issue_127287
Improve message prefer a domain-qualified finalizer
This commit is contained in:
commit
8d402c9941
@ -86,7 +86,11 @@ func validateKubeFinalizerName(stringValue string, fldPath *field.Path) []string
|
||||
}
|
||||
if len(strings.Split(stringValue, "/")) == 1 {
|
||||
if !standardFinalizers.Has(stringValue) {
|
||||
allWarnings = append(allWarnings, fmt.Sprintf("%s: %q: prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers", fldPath.String(), stringValue))
|
||||
if strings.Contains(stringValue, ".") {
|
||||
allWarnings = append(allWarnings, fmt.Sprintf("%s: %q: prefer a domain-qualified finalizer name including a path (/) to avoid accidental conflicts with other finalizer writers", fldPath.String(), stringValue))
|
||||
} else {
|
||||
allWarnings = append(allWarnings, fmt.Sprintf("%s: %q: prefer a domain-qualified finalizer name to avoid accidental conflicts with other finalizer writers", fldPath.String(), stringValue))
|
||||
}
|
||||
}
|
||||
}
|
||||
return allWarnings
|
||||
|
@ -2937,6 +2937,13 @@ func testFinalizerValidationApplyCreateAndUpdateCRD(t *testing.T, rest rest.Inte
|
||||
name: "create-crd-with-valid-finalizer",
|
||||
finalizer: []string{"kubernetes.io/valid-finalizer"},
|
||||
},
|
||||
{
|
||||
name: "create-crd-with-fqdn-like-finalizer-without-path",
|
||||
finalizer: []string{"finalizer.without.valid-path.io"},
|
||||
expectCreateWarnings: []string{
|
||||
`metadata.finalizers: "finalizer.without.valid-path.io": prefer a domain-qualified finalizer name including a path (/) to avoid accidental conflicts with other finalizer writers`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "update-crd-with-invalid-finalizer",
|
||||
finalizer: []string{"invalid-finalizer"},
|
||||
|
Loading…
Reference in New Issue
Block a user