File tree 6 files changed +51
-13
lines changed
6 files changed +51
-13
lines changed Original file line number Diff line number Diff line change @@ -2,11 +2,16 @@ package simple
2
2
3
3
import (
4
4
"github.com/kyverno/chainsaw/pkg/client"
5
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5
6
"k8s.io/client-go/rest"
6
7
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
7
8
)
8
9
9
10
func New (cfg * rest.Config ) (client.Client , error ) {
10
11
var opts ctrlclient.Options
11
- return ctrlclient .New (cfg , opts )
12
+ client , err := ctrlclient .New (cfg , opts )
13
+ if err != nil {
14
+ return nil , err
15
+ }
16
+ return ctrlclient .WithFieldValidation (client , metav1 .FieldValidationStrict ), nil
12
17
}
Original file line number Diff line number Diff line change 12
12
- [ delete] ( delete/README.md )
13
13
- [ deployment] ( deployment/README.md )
14
14
- [ dynamic-clusters] ( dynamic-clusters/README.md )
15
+ - [ field-validation] ( field-validation/README.md )
15
16
- [ finally] ( finally/README.md )
16
17
- [ inline] ( inline/README.md )
17
18
- [ k8s-server-version] ( k8s-server-version/README.md )
Original file line number Diff line number Diff line change
1
+ # Test: ` field-validation `
2
+
3
+ * No description*
4
+
5
+ ## Steps
6
+
7
+ | # | Name | Bindings | Try | Catch | Finally | Cleanup |
8
+ | :-:| ---| :-:| :-:| :-:| :-:|
9
+ | 1 | [ step-1] ( #step-step-1 ) | 0 | 1 | 0 | 0 | 0 |
10
+
11
+ ### Step: ` step-1 `
12
+
13
+ * No description*
14
+
15
+ #### Try
16
+
17
+ | # | Operation | Bindings | Outputs | Description |
18
+ | :-:| ---| :-:| :-:| ---|
19
+ | 1 | ` apply ` | 0 | 0 | * No description* |
20
+
21
+ ---
22
+
Original file line number Diff line number Diff line change
1
+ # yaml-language-server: $schema=../../../../.schemas/json/test-chainsaw-v1alpha1.json
2
+ apiVersion : chainsaw.kyverno.io/v1alpha1
3
+ kind : Test
4
+ metadata :
5
+ name : field-validation
6
+ spec :
7
+ steps :
8
+ - try :
9
+ - apply :
10
+ resource :
11
+ apiVersion : v1
12
+ kind : ConfigMap
13
+ metadata :
14
+ name : chainsaw-quick-start
15
+ data :
16
+ foo : bar
17
+ bar : baz
18
+ expect :
19
+ - check :
20
+ ($error) : |-
21
+ ConfigMap in version "v1" cannot be handled as a ConfigMap: strict decoding error: unknown field "bar"
Original file line number Diff line number Diff line change 6
6
7
7
| # | Name | Bindings | Try | Catch | Finally | Cleanup |
8
8
| :-:| ---| :-:| :-:| :-:| :-:|
9
- | 1 | [ step-1] ( #step-step-1 ) | 0 | 3 | 0 | 0 | 0 |
9
+ | 1 | [ step-1] ( #step-step-1 ) | 0 | 2 | 0 | 0 | 0 |
10
10
11
11
### Step: ` step-1 `
12
12
18
18
| :-:| ---| :-:| :-:| ---|
19
19
| 1 | ` apply ` | 0 | 0 | * No description* |
20
20
| 2 | ` assert ` | 0 | 0 | * No description* |
21
- | 3 | ` error ` | 0 | 0 | * No description* |
22
21
23
22
---
24
23
Original file line number Diff line number Diff line change 14
14
- assert :
15
15
# file is relative to the test folder
16
16
file : configmap.yaml
17
- # this make sure a non-existent field cannot be compared to an empty object
18
- - error :
19
- resource :
20
- apiVersion : v1
21
- kind : ConfigMap
22
- metadata :
23
- name : chainsaw-quick-start
24
- status :
25
- vulnerabilitySummary :
26
- severityCount : {}
You can’t perform that action at this time.
0 commit comments