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