Skip to content

Commit

Permalink
908: improve validate support
Browse files Browse the repository at this point in the history
  • Loading branch information
ademariag committed Dec 17, 2022
1 parent 45d1858 commit 4d26f2f
Show file tree
Hide file tree
Showing 10 changed files with 12,478 additions and 132 deletions.
22 changes: 13 additions & 9 deletions docs/pages/commands/kapitan_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,16 @@ Validates the schema of compiled output. Validate options are specified in the i

**Kubernetes** has different resource kinds, for instance:

- `service`
- `deployment`
- `statefulset`
- `Service`
- `Deployment`
- `Statefulset`

**Kapitan** has built in support for validation of **Kubernetes** kinds, and automatically integrates with [kapicorp/kubernetes-json-schema](https://github.com/kapicorp/kubernetes-json-schema)

**Kapitan** has built in support for validation of **Kubernetes** kinds, and automatically integrates with <https://kubernetesjsonschema.dev>. See [github.com/instrumenta/kubernetes-json-schema](https://github.com/instrumenta/kubernetes-json-schema) for more informations.

!!! info

**Kapitan** will automatically download the schemas for Kubernetes Manifests directly from <https://kubernetesjsonschema.dev>
**Kapitan** will automatically download the schemas for Kubernetes Manifests directly from [kapicorp/kubernetes-json-schema](https://github.com/kapicorp/kubernetes-json-schema)

By default, the schemas are cached into `./schemas/`, which can be modified with the `--schemas-path` option.

Expand All @@ -109,11 +110,14 @@ Validates the schema of compiled output. Validate options are specified in the i

Refer to the `mysql` example.

```yaml hl_lines="2-6" title="kubernetes/inventory/classes/component/mysql.yml"
```yaml hl_lines="2-12" title="kubernetes/inventory/classes/component/mysql.yml"
--8<-- "kubernetes/inventory/classes/component/mysql.yml:19:30"
```

1. **`type`** | currently only **Kubernetes** is supported
2. **`output_paths`** | list of files to validate
3. **`kind`** | a **Kubernetes** resource kind
4. **`version`** | a Kubernetes API version, defaults to **`1.14.0`**
2. **`output_paths`** | list of paths to validate, with supports for glob patterns
3. **`fail_on_error`** | whether to fail compilation on error, defaults to **`True`**
4. **`version`** | a Kubernetes API version, defaults to **`1.26.0`**
5. **`verbose`** | whether to also print successful validations, defaults to **`False`**
6. **`exclude.kind`** | list of Kubernetes kinds to exclude.
7. **`exclude.paths`** | list of paths to exclude.
20 changes: 10 additions & 10 deletions examples/kubernetes/inventory/classes/component/mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ parameters:
input_paths:
- docs/mysql/README.md
validate:
- type: kubernetes # mkdocs (1)!
- type: kubernetes # mkdocs (1)!
fail_on_error: true # mkdocs (3)!
verbose: true # mkdocs (5)!
exclude:
kinds: # mkdocs (6)!
- StatefulSet
paths: # mkdocs (7)!
- manifest/excluded_from_validation.yml
output_paths: # mkdocs (2)!
- manifests/mysql_secret.yml
kind: secret # temporarily replaced with 'deployment' during test # mkdocs (3)!
version: 1.14.0 # optional, defaults to 1.14.0 # mkdocs (4)!
- type: kubernetes
output_paths:
- manifests/mysql_service_jsonnet.yml
- manifests/mysql_service_simple.yml
kind: service
version: 1.14.0
- manifests/*.yml
version: 1.26.0 # optional, defaults to 1.26.0 # mkdocs (4)!
# For vaultkv secrets it is important to declare auth in parameters
secrets:
vaultkv:
Expand Down
Loading

0 comments on commit 4d26f2f

Please sign in to comment.