validate
Validate Flipt flag state (.yaml, .yml) files
flipt validate [flags]
Options
-e, --extra-schema string path to extra schema constraints
-F, --format string output format: json, text (default "text")
-h, --help help for validate
--issue-exit-code int exit code to use when issues are found (default 1)
-d, --work-dir set the working directory
Behavior
This command validates Flipt’s declarative feature configuration files.
It looks for features flag definitions in the same way as Flipt’s declarative backends. Checkout the documentation on locating flag state to learn more about this process.
Extra Schema
The flag --extra-schema
(short form -e
) can be used to pass additional constraints via a CUE schema file.
This file will be unified with the base schema used within flipt validate
to ensure the format of Flipt files.
You can find the base schema here.
As an example, take the following flipt features.yaml
file:
flags:
- key: someFeature
name: Some Feature
Running validate will succeed when provided with a path to this file.
➜ flipt validate
➜ echo $?
0
By default, the flag description
field is not required. However, imagine that you want to ensure this field is always provided with a non-empty string. You can do this via the --extra-schema
flag and a CUE definition.
In this instance we’re going to create a CUE file named extended.cue
.
Within this file we will add a constraint to the #Flag
CUE definition, which ensures our desired behavior.
#Flag: {
description: =~"^.+$"
}
This definition ensures that description is both supplied and that the value matches the regular expression. The regular expression in this example ensures a string with a length of at least 1 character.
Now when invoking the validate sub-command, we pass the path to this extra CUE definition:
➜ flipt validate -e extended.cue
Validation failed!
- Message : flags.0.description: incomplete value =~"^.+$"
File : features.yaml
Line : 2
Here we see that our additional constraint on description is being validated and described in the output.
More Info
See the flag state section of the documentation for more information.