mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Improve message prefer a domain-qualified finalizer
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
This commit is contained in:
		@@ -86,9 +86,13 @@ func validateKubeFinalizerName(stringValue string, fldPath *field.Path) []string
 | 
			
		||||
	}
 | 
			
		||||
	if len(strings.Split(stringValue, "/")) == 1 {
 | 
			
		||||
		if !standardFinalizers.Has(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"},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user