-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kubernetes: Ignore internal K8S annotations
- Loading branch information
1 parent
863182e
commit be2d4d1
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
func TestIsInternalAnnotationKey(t *testing.T) { | ||
testCases := []struct { | ||
Key string | ||
Expected bool | ||
}{ | ||
{"", false}, | ||
{"anyKey", false}, | ||
{"any.hostname.io", false}, | ||
{"any.hostname.com/with/path", false}, | ||
{"any.kubernetes.io", true}, | ||
{"kubernetes.io", true}, | ||
{"pv.kubernetes.io/any/path", true}, | ||
} | ||
for i, tc := range testCases { | ||
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { | ||
isInternal := isInternalAnnotationKey(tc.Key) | ||
if tc.Expected && isInternal != tc.Expected { | ||
t.Fatalf("Expected %q to be internal", tc.Key) | ||
} | ||
if !tc.Expected && isInternal != tc.Expected { | ||
t.Fatalf("Expected %q not to be internal", tc.Key) | ||
} | ||
}) | ||
} | ||
} |