You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,9 @@ policies:
86
86
resources:
87
87
- <path/to/resource.yaml>
88
88
- <path/to/resource.yaml>
89
+
schemaLocations: # Optional: For Custom Resources
90
+
- <url/to/crd/schema.json>
91
+
- <path/to/crd/schema.json>
89
92
vapTestSuites:
90
93
- policy: <name> # ValidatingAdmissionPolicy's name
91
94
tests:
@@ -153,6 +156,17 @@ kaptest run <path/to/test_manifest.yaml> ...
153
156
154
157
You can run test cases of multiple YAML files at once and display the test results together.
155
158
159
+
#### Resource Manifest Validation
160
+
161
+
kaptest incorporates [kubeconform](https://github.com/yannh/kubeconform) based manifest validation.
162
+
All resources including policies need to follow schema.
163
+
164
+
For custom resources, users need to define `schemaLocations` in a test policy to get CRD schema.
165
+
The schema specification follows kubeconform's one and users can utlize schemas for it.
166
+
The example is described in [internal/tester/testdata/vap-custom-resources.test/kaptest.yaml](./internal/tester/testdata/vap-custom-resources.test/kaptest.yaml).
167
+
168
+
`kaptest run <test_manifest.yaml> --validate-resource-manifests=false`disables the validation.
169
+
156
170
### Operation Type
157
171
158
172
You can describe the cases for CREATE, UPDATE, and DELETE operations based on whether object and oldObject are specified. These are determined by the following conditions:
cmd.Flags().BoolVarP(&testerCfg.ValidateResourceManifest, "validate-resource-manifests", "", true, "Validating the resource manifests according to the schema")
47
+
cmd.Flags().StringVarP(&testerCfg.SchemaCache, "schema-cache", "", filepath.Join(homeDir, ".cache/kaptest/schema"), "Path to cache schemas used in resource manifest validation")
0 commit comments