Skip to main content

CLI arguments

Running a policy check

The minimum input that's required to trigger a policy check is to use the command datree test and to provide a Kubernetes configuration file path or a glob pattern:

$ datree test kube-prod/deployment.yaml
$ datree test kube-*/*.yaml


--help-hN/APrint help. If a command is provided, help will be printed for that command
--output-ojson, yaml, xml, JUnitOutput the policy check results in the requested format
--output-osimpleOutput the policy check results in simple text (without emoji or colors)
--schema-version-se.g. "1.20.0"Set Kubernetes version to validate against. Default can also be changed from the dashboard
--schema-locationN/Ae.g. "http\://"Override Kubernetes schema location. See relevant page for more information.
--ignore-missing-schemasN/AN/ASkip files with missing schemas instead of failing the schema validation check
--policy-pe.g. stagingSpecify which policy to execute (by policy name)
--only-k8s-filesN/AN/ASkip all non-K8s files. Especially useful when scanning a dir with K8s and other config files: datree test *.yaml --only-k8s-files
--no-recordN/AN/ADon’t send policy checks metadata to the backend
--verboseN/AN/ADisplay 'How to Fix' link for failed rules in output

Additional options

Built-in Kustomize support

Run datree kustomize test [path] to render resources defined in a kustomization.yaml file located in [path] and run a policy check against them. For more information, options and examples, see the Kustomize support page.

Publish policy-as-code configuration

When using Policy as code mode, the command datree publish fileName.yaml will publish policies configuration for given fileName. Input should be the path to the Policy-as-Code yaml configuration file.

Configure the CLI

The command datree config allows you to manage the datree config file. Use datree config set to change the value of a specific key in the datree config.yaml file (defaults to $HOME/.datree/config.yaml). For example:

$ datree config set token MY_EXAMPLE_TOKEN