File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
staging/src/k8s.io/apiserver/pkg/admission/plugin/resourcequota Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import (
29
29
30
30
var (
31
31
scheme = runtime .NewScheme ()
32
- codecs = serializer .NewCodecFactory (scheme )
32
+ codecs = serializer .NewCodecFactory (scheme , serializer . EnableStrict )
33
33
)
34
34
35
35
func init () {
Original file line number Diff line number Diff line change @@ -43,6 +43,34 @@ func TestLoadConfiguration(t *testing.T) {
43
43
input : `{"kind":"Unknown","apiVersion":"v1"}` ,
44
44
expectErr : `no kind "Unknown" is registered` ,
45
45
},
46
+ {
47
+ name : "duplicate field error; strict validation" ,
48
+ input : `
49
+ kind: ResourceQuotaConfiguration
50
+ apiVersion: apiserver.config.k8s.io/v1
51
+ limitedResources:
52
+ - apiGroup: ""
53
+ resource: persistentvolumeclaims
54
+ resource: persistentvolumeclaims
55
+ matchContains:
56
+ - .storageclass.storage.k8s.io/requests.storage
57
+ ` ,
58
+ expectErr : `strict decoding error` ,
59
+ },
60
+ {
61
+ name : "unknown field error; strict validation" ,
62
+ input : `
63
+ kind: ResourceQuotaConfiguration
64
+ apiVersion: apiserver.config.k8s.io/v1
65
+ limitedResources:
66
+ - apiGroup: ""
67
+ foo: bar
68
+ resource: persistentvolumeclaims
69
+ matchContains:
70
+ - .storageclass.storage.k8s.io/requests.storage
71
+ ` ,
72
+ expectErr : `strict decoding error` ,
73
+ },
46
74
{
47
75
name : "valid v1alpha1 config" ,
48
76
input : `
You can’t perform that action at this time.
0 commit comments