Skip to content

Commit 2a80b26

Browse files
committed
Fix examples and test cases
There are examples oversighted by the test case. This PR adds those paths to the test case and fixes the errors identified.
1 parent 83bf2a4 commit 2a80b26

File tree

3 files changed

+97
-47
lines changed

3 files changed

+97
-47
lines changed

content/en/examples/application/ssa/nginx-deployment-replicas-only.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,18 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: nginx-deployment
5+
labels:
6+
app: nginx
57
spec:
8+
selector:
9+
matchLabels:
10+
app: nginx
611
replicas: 3
12+
template:
13+
metadata:
14+
labels:
15+
app: nginx
16+
spec:
17+
containers:
18+
- name: nginx
19+
image: nginx:1.14.2

content/en/examples/examples_test.go

Lines changed: 73 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ import (
4646
api "k8s.io/kubernetes/pkg/apis/core"
4747
"k8s.io/kubernetes/pkg/apis/core/validation"
4848

49+
// "k8s.io/kubernetes/pkg/apis/flowcontrol"
50+
// flowcontrol_validation "k8s.io/kubernetes/pkg/apis/flowcontrol/validation"
51+
4952
"k8s.io/kubernetes/pkg/apis/networking"
5053
networking_validation "k8s.io/kubernetes/pkg/apis/networking/validation"
5154

@@ -253,11 +256,31 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
253256
t.Namespace = api.NamespaceDefault
254257
}
255258
errors = apps_validation.ValidateStatefulSet(t, podValidationOptions)
259+
case *apps.DaemonSet:
260+
if t.Namespace == "" {
261+
t.Namespace = api.NamespaceDefault
262+
}
263+
errors = apps_validation.ValidateDaemonSet(t, podValidationOptions)
264+
case *apps.Deployment:
265+
if t.Namespace == "" {
266+
t.Namespace = api.NamespaceDefault
267+
}
268+
errors = apps_validation.ValidateDeployment(t, podValidationOptions)
269+
case *apps.ReplicaSet:
270+
if t.Namespace == "" {
271+
t.Namespace = api.NamespaceDefault
272+
}
273+
errors = apps_validation.ValidateReplicaSet(t, podValidationOptions)
256274
case *autoscaling.HorizontalPodAutoscaler:
257275
if t.Namespace == "" {
258276
t.Namespace = api.NamespaceDefault
259277
}
260278
errors = autoscaling_validation.ValidateHorizontalPodAutoscaler(t)
279+
case *batch.CronJob:
280+
if t.Namespace == "" {
281+
t.Namespace = api.NamespaceDefault
282+
}
283+
errors = batch_validation.ValidateCronJobCreate(t, podValidationOptions)
261284
case *batch.Job:
262285
if t.Namespace == "" {
263286
t.Namespace = api.NamespaceDefault
@@ -269,50 +292,23 @@ func validateObject(obj runtime.Object) (errors field.ErrorList) {
269292
t.ObjectMeta.Name = "skip-for-good"
270293
}
271294
errors = job.Strategy.Validate(nil, t)
272-
case *apps.DaemonSet:
273-
if t.Namespace == "" {
274-
t.Namespace = api.NamespaceDefault
275-
}
276-
errors = apps_validation.ValidateDaemonSet(t, podValidationOptions)
277-
case *apps.Deployment:
278-
if t.Namespace == "" {
279-
t.Namespace = api.NamespaceDefault
280-
}
281-
errors = apps_validation.ValidateDeployment(t, podValidationOptions)
295+
// case *flowcontrol.FlowSchema:
296+
// TODO: This is still failing
297+
// errors = flowcontrol_validation.ValidateFlowSchema(t)
282298
case *networking.Ingress:
283299
if t.Namespace == "" {
284300
t.Namespace = api.NamespaceDefault
285301
}
286302
errors = networking_validation.ValidateIngressCreate(t)
287303
case *networking.IngressClass:
288-
/*
289-
if t.Namespace == "" {
290-
t.Namespace = api.NamespaceDefault
291-
}
292-
gv := schema.GroupVersion{
293-
Group: networking.GroupName,
294-
Version: legacyscheme.Scheme.PrioritizedVersionsForGroup(networking.GroupName)[0].Version,
295-
}
296-
*/
297304
errors = networking_validation.ValidateIngressClass(t)
298-
299-
case *policy.PodSecurityPolicy:
300-
errors = policy_validation.ValidatePodSecurityPolicy(t)
301-
case *apps.ReplicaSet:
302-
if t.Namespace == "" {
303-
t.Namespace = api.NamespaceDefault
304-
}
305-
errors = apps_validation.ValidateReplicaSet(t, podValidationOptions)
306-
case *batch.CronJob:
307-
if t.Namespace == "" {
308-
t.Namespace = api.NamespaceDefault
309-
}
310-
errors = batch_validation.ValidateCronJobCreate(t, podValidationOptions)
311305
case *networking.NetworkPolicy:
312306
if t.Namespace == "" {
313307
t.Namespace = api.NamespaceDefault
314308
}
315309
errors = networking_validation.ValidateNetworkPolicy(t, netValidationOptions)
310+
case *policy.PodSecurityPolicy:
311+
errors = policy_validation.ValidatePodSecurityPolicy(t)
316312
case *policy.PodDisruptionBudget:
317313
if t.Namespace == "" {
318314
t.Namespace = api.NamespaceDefault
@@ -391,6 +387,14 @@ func TestExampleObjectSchemas(t *testing.T) {
391387

392388
// Please help maintain the alphabeta order in the map
393389
cases := map[string]map[string][]runtime.Object{
390+
"access": {
391+
"endpoints-aggregated": {&rbac.ClusterRole{}},
392+
},
393+
"access/certificate-signing-request": {
394+
"clusterrole-approve": {&rbac.ClusterRole{}},
395+
"clusterrole-create": {&rbac.ClusterRole{}},
396+
"clusterrole-sign": {&rbac.ClusterRole{}},
397+
},
394398
"admin": {
395399
"namespace-dev": {&api.Namespace{}},
396400
"namespace-prod": {&api.Namespace{}},
@@ -404,6 +408,7 @@ func TestExampleObjectSchemas(t *testing.T) {
404408
"dns-horizontal-autoscaler": {&api.ServiceAccount{}, &rbac.ClusterRole{}, &rbac.ClusterRoleBinding{}, &apps.Deployment{}},
405409
"dnsutils": {&api.Pod{}},
406410
},
411+
// TODO: "admin/konnectivity" is not include yet.
407412
"admin/logging": {
408413
"fluentd-sidecar-config": {&api.ConfigMap{}},
409414
"two-files-counter-pod": {&api.Pod{}},
@@ -482,10 +487,6 @@ func TestExampleObjectSchemas(t *testing.T) {
482487
"application/hpa": {
483488
"php-apache": {&autoscaling.HorizontalPodAutoscaler{}},
484489
},
485-
"application/nginx": {
486-
"nginx-deployment": {&apps.Deployment{}},
487-
"nginx-svc": {&api.Service{}},
488-
},
489490
"application/job": {
490491
"cronjob": {&batch.CronJob{}},
491492
"job-tmpl": {&batch.Job{}},
@@ -500,13 +501,26 @@ func TestExampleObjectSchemas(t *testing.T) {
500501
"redis-pod": {&api.Pod{}},
501502
"redis-service": {&api.Service{}},
502503
},
504+
"application/mongodb": {
505+
"mongo-deployment": {&apps.Deployment{}},
506+
"mongo-service": {&api.Service{}},
507+
},
503508
"application/mysql": {
504509
"mysql-configmap": {&api.ConfigMap{}},
505510
"mysql-deployment": {&api.Service{}, &apps.Deployment{}},
506511
"mysql-pv": {&api.PersistentVolume{}, &api.PersistentVolumeClaim{}},
507512
"mysql-services": {&api.Service{}, &api.Service{}},
508513
"mysql-statefulset": {&apps.StatefulSet{}},
509514
},
515+
"application/nginx": {
516+
"nginx-deployment": {&apps.Deployment{}},
517+
"nginx-svc": {&api.Service{}},
518+
},
519+
"application/ssa": {
520+
"nginx-deployment": {&apps.Deployment{}},
521+
"nginx-deployment-no-replicas": {&apps.Deployment{}},
522+
"nginx-deployment-replicas-only": {&apps.Deployment{}},
523+
},
510524
"application/web": {
511525
"web": {&api.Service{}, &apps.StatefulSet{}},
512526
"web-parallel": {&api.Service{}, &apps.StatefulSet{}},
@@ -518,6 +532,11 @@ func TestExampleObjectSchemas(t *testing.T) {
518532
"application/zookeeper": {
519533
"zookeeper": {&api.Service{}, &api.Service{}, &policy.PodDisruptionBudget{}, &apps.StatefulSet{}},
520534
},
535+
"concepts/policy/limit-range": {
536+
"example-conflict-with-limitrange-cpu": {&api.Pod{}},
537+
"problematic-limit-range": {&api.LimitRange{}},
538+
"example-no-conflict-with-limitrange-cpu": {&api.Pod{}},
539+
},
521540
"configmap": {
522541
"configmaps": {&api.ConfigMap{}, &api.ConfigMap{}},
523542
"configmap-multikeys": {&api.ConfigMap{}},
@@ -635,6 +654,11 @@ func TestExampleObjectSchemas(t *testing.T) {
635654
"pv-volume": {&api.PersistentVolume{}},
636655
"redis": {&api.Pod{}},
637656
},
657+
"pods/topology-spread-constraints": {
658+
"one-constraint": {&api.Pod{}},
659+
"one-constraint-with-nodeaffinity": {&api.Pod{}},
660+
"two-constraints": {&api.Pod{}},
661+
},
638662
"policy": {
639663
"baseline-psp": {&policy.PodSecurityPolicy{}},
640664
"example-psp": {&policy.PodSecurityPolicy{}},
@@ -644,6 +668,19 @@ func TestExampleObjectSchemas(t *testing.T) {
644668
"zookeeper-pod-disruption-budget-maxunavailable": {&policy.PodDisruptionBudget{}},
645669
"zookeeper-pod-disruption-budget-minavailable": {&policy.PodDisruptionBudget{}},
646670
},
671+
/* TODO: This doesn't work yet.
672+
"priority-and-fairness": {
673+
"health-for-strangers": {&flowcontrol.FlowSchema{}},
674+
},
675+
*/
676+
"secret/serviceaccount": {
677+
"mysecretname": {&api.Secret{}},
678+
},
679+
"security": {
680+
"podsecurity-baseline": {&api.Namespace{}},
681+
"podsecurity-privileged": {&api.Namespace{}},
682+
"podsecurity-restricted": {&api.Namespace{}},
683+
},
647684
"service": {
648685
"nginx-service": {&api.Service{}},
649686
"load-balancer-example": {&apps.Deployment{}},

content/en/examples/priority-and-fairness/health-for-strangers.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ spec:
77
priorityLevelConfiguration:
88
name: exempt
99
rules:
10-
- nonResourceRules:
11-
- nonResourceURLs:
12-
- "/healthz"
13-
- "/livez"
14-
- "/readyz"
15-
verbs:
16-
- "*"
17-
subjects:
18-
- kind: Group
19-
group:
20-
name: system:unauthenticated
10+
- nonResourceRules:
11+
- nonResourceURLs:
12+
- "/healthz"
13+
- "/livez"
14+
- "/readyz"
15+
verbs:
16+
- "*"
17+
subjects:
18+
- kind: Group
19+
group:
20+
name: "system:unauthenticated"

0 commit comments

Comments
 (0)