Skip to content

Commit 4683d58

Browse files
author
Sebastiaan Verbeek
authored
feat: added documentation for schema validation (#240)
1 parent 8735c8d commit 4683d58

File tree

3 files changed

+65
-4
lines changed

3 files changed

+65
-4
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ export ENV_DIR=$PWD/../otomi-values CLOUD=google CLUSTER=demo
3333

3434
### 1. Validating changes
3535

36-
You can check wether resulting manifests violate any of our output checks:
36+
You can check whether resulting manifests violate any of our output checks:
3737

3838
```bash
3939
otomi validate-templates
4040
```
4141

42-
This will check wether any CRs are matching their CRDs, but also check for k8s manifest best practices using [kubeval](https://www.kubeval.com).
42+
This will check whether any CRs are matching their CRDs, but also check for k8s manifest best practices using [kubeval](https://www.kubeval.com).
4343

44-
We are also integrating another solution based on [conftest](https://www.conftest.dev). It allows to create OPA policies that are used both for statical analysis (at build time), as well as by [gatekeeper](https://github.com/open-policy-agent/gatekeeper) (at run time) to check wether manifests are conformant.
44+
We are also integrating another solution based on [conftest](https://www.conftest.dev). It allows to create OPA policies that are used both for statical analysis (at build time), as well as by [gatekeeper](https://github.com/open-policy-agent/gatekeeper) (at run time) to check whether manifests are conformant.
45+
46+
There is in-built meta-schema validation for editing `otomi-values`-files. Refer to [meta-schema documentation](./docs/meta-schema-validation.md).
4547

4648
### 2. Diffing changes
4749

docs/meta-schema-validation.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Meta-schema validation
2+
3+
We validate `values-schema.yaml` using JSON Schema. Refer to `values-schema.yaml` for the supported `$schema`, it should always be on top of the file for easy reference.
4+
5+
## Guidelines for describing strings
6+
7+
By having accurate and consistent descriptions (refer to `description` keys in `values-schema.yaml`), we can provide a better experience in configuring `otomi-values`. Refer to the [Kubernetes API documentation](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#validation) on conventions for description writing.
8+
9+
### Examples
10+
11+
Excellent:
12+
13+
```
14+
15+
oauth2-proxy:
16+
type: object
17+
additionalProperties: false
18+
properties:
19+
config:
20+
type: object
21+
properties:
22+
cookieSecret:
23+
type: string
24+
description: Cookie secret must be 128 bit base64 encoded string.
25+
pattern: ^(?:[A-Za-z0-9+/]{4})\\\*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?\$
26+
27+
```
28+
29+
Seeing a small improvement:
30+
31+
```
32+
33+
armAuth:
34+
type: object
35+
additionalProperties: false
36+
description: A service Principal secret
37+
properties:
38+
secretJSON:
39+
description: A service Principal secret JSON key (base64 encoded)
40+
type: string
41+
42+
```
43+
44+
This could be modified to:
45+
46+
```
47+
48+
armAuth:
49+
type: object
50+
additionalProperties: false
51+
description: A service Principal secret
52+
properties:
53+
secretJSON:
54+
description: Must be a service Principal secret JSON key (base64 encoded)
55+
type: string
56+
57+
```
58+
59+
etc.

values-schema.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ properties:
850850
- subnetPrefix
851851
armAuth:
852852
additionalProperties: false
853-
description: A service Principal secret ey An explanation about the purpose of this instance.
853+
description: A service Principal secret
854854
properties:
855855
secretJSON:
856856
description: A service Principal secret JSON key (base64 encoded)

0 commit comments

Comments
 (0)