Skip to content

Commit ef936a1

Browse files
committed
Fix example test for working with 1.26 code base
This commit updates the validation logic by adding new validation options required by 1.26 and also adds new YAMLs to the test cases.
1 parent ae11313 commit ef936a1

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

content/en/examples/examples_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,17 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
152152
AllowDownwardAPIHugePages: true,
153153
AllowInvalidPodDeletionCost: false,
154154
AllowIndivisibleHugePagesValues: true,
155-
AllowWindowsHostProcessField: true,
156155
AllowExpandedDNSConfig: true,
157156
}
157+
netValidationOptions := networking_validation.NetworkPolicyValidationOptions{
158+
AllowInvalidLabelValueInSelector: false,
159+
}
160+
pdbValidationOptions := policy_validation.PodDisruptionBudgetValidationOptions{
161+
AllowInvalidLabelValueInSelector: false,
162+
}
163+
clusterroleValidationOptions := rbac_validation.ClusterRoleValidationOptions{
164+
AllowInvalidLabelValueInSelector: false,
165+
}
158166

159167
// Enable CustomPodDNS for testing
160168
// feature.DefaultFeatureGate.Set("CustomPodDNS=true")
@@ -304,15 +312,15 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
304312
if t.Namespace == "" {
305313
t.Namespace = api.NamespaceDefault
306314
}
307-
errors = networking_validation.ValidateNetworkPolicy(t)
315+
errors = networking_validation.ValidateNetworkPolicy(t, netValidationOptions)
308316
case *policy.PodDisruptionBudget:
309317
if t.Namespace == "" {
310318
t.Namespace = api.NamespaceDefault
311319
}
312-
errors = policy_validation.ValidatePodDisruptionBudget(t)
320+
errors = policy_validation.ValidatePodDisruptionBudget(t, pdbValidationOptions)
313321
case *rbac.ClusterRole:
314322
// clusterole does not accept namespace
315-
errors = rbac_validation.ValidateClusterRole(t)
323+
errors = rbac_validation.ValidateClusterRole(t, clusterroleValidationOptions)
316324
case *rbac.ClusterRoleBinding:
317325
// clusterolebinding does not accept namespace
318326
errors = rbac_validation.ValidateClusterRoleBinding(t)
@@ -559,7 +567,9 @@ func TestExampleObjectSchemas(t *testing.T) {
559567
"pod-with-affinity-anti-affinity": {&api.Pod{}},
560568
"pod-with-node-affinity": {&api.Pod{}},
561569
"pod-with-pod-affinity": {&api.Pod{}},
570+
"pod-with-scheduling-gates": {&api.Pod{}},
562571
"pod-with-toleration": {&api.Pod{}},
572+
"pod-without-scheduling-gates": {&api.Pod{}},
563573
"private-reg-pod": {&api.Pod{}},
564574
"share-process-namespace": {&api.Pod{}},
565575
"simple-pod": {&api.Pod{}},

0 commit comments

Comments
 (0)