Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

908: improve validate support #910

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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