Skip to content

Commit

Permalink
Merge pull request #127303 from omerap12/issue_127287
Browse files Browse the repository at this point in the history
Improve message prefer a domain-qualified finalizer
  • Loading branch information
k8s-ci-robot committed Sep 13, 2024
2 parents 359b9ba + 6aa674d commit 8d402c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions test/integration/apiserver/field_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit 8d402c9

Please sign in to comment.