Skip to content

validate commandΒΆ

nais validate path/to/nais.yaml

Use multiple arguments to validate multiple files:

nais validate path/to/nais.yaml path/to/another/nais.yaml

Available flags:

Flag Required Short Description
vars No path to FILE containing template variables, must be JSON or YAML format
var No template variable in KEY=VALUE form, can either be a comma separated list or specified multiple times.
verbose No -v print all the template variables and final resources after templating

All flags must be specified before arguments:

nais validate [--vars path/to/vars.(yaml|json)] [--var key=value] path/to/nais.yaml 

See the templating section for examples.

Supported ResourcesΒΆ

The following resource kinds are supported:

TemplatingΒΆ

A templated YAML file can look like this:

nais.yaml
apiVersion: nais.io/v1alpha1
kind: Application
metadata:
  name: {{app}}
  namespace: some-team
  labels:
    team: some-team
spec:
  image: {{image}}

To validate a templated file, provide a variable file or specify the variables as flags.

Variable FileΒΆ

The variable file must be in either JSON or YAML format:

vars.json
{
  "app": "some-app",
  "image": "some-image"
}
vars.yaml
app: some-app
image: some-image

Specify the path to the variable file with the --vars flag:

nais validate --vars vars.yaml nais.yaml

Variable FlagsΒΆ

Specify variables in the key=value form with the --var flag. Multiple variables can be provided as a comma separated list of pairs:

nais validate --var app=app,image=image nais.yaml

...or by specifying the --var flag multiple times:

nais validate --var app=app --var image=image nais.yaml

If both a variable file and variable flags are provided:

nais validate --vars vars.yaml --var image=some-other-image nais.yaml

...the flags will override any variables set by the file:

nais validate --vars vars.yaml --var image=some-other-image -v nais.yaml

[πŸ“] Setting template variable 'app' to 'some-app'
[πŸ“] Setting template variable 'image' to 'some-image'
[⚠️] Overwriting template variable 'image'; previous value was 'some-image'
[πŸ“] Setting template variable 'image' to 'some-other-image'
...

Verbose OutputΒΆ

The --verbose (shorthand -v) flag prints additional information, such as template variables set and the final templated resources:

nais validate --vars vars.yaml --verbose nais.yaml
[πŸ“] Setting template variable 'app' to 'some-app'
[πŸ“] Setting template variable 'image' to 'some-image'
[πŸ–¨οΈ] Printing "nais.yaml"...
---
apiVersion: nais.io/v1alpha1
kind: Application
metadata:
  name: some-app
  namespace: some-team
  labels:
    team: some-team
spec:
  image: some-image

[βœ…] "nais.yaml" is valid