Skip to content

Commit

Permalink
VS Code schema validation (#884)
Browse files Browse the repository at this point in the history
## Description

<!-- Please include a summary of the change. Any relevant motivation or
context is also helpful, as well as any dependencies that are required
for this change -->

Add documentation to be able to use `zarf.schema.json` as YAML
validation for `zarf.yaml` in VS Code.

## Related Issue

<!--- This project prefers to accept pull requests related to open
issues -->
<!--- If suggesting a new feature or change, please discuss it in an
issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps
to reproduce -->

Fixes #872 

## Type of change

<!-- Please delete options that are not relevant -->

- [x] Documentation addition / change

## Checklist before merging

<!-- Please delete options that are not relevant -->

- [x] Documentation has been updated as necessary (add the `needs-docs`
label)

Co-authored-by: Megamind <[email protected]>
  • Loading branch information
Noxsios and jeff-mccoy authored Oct 13, 2022
1 parent 20cf67d commit c7202d2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/4-user-guide/4-vscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Getting started - VS Code

Zarf uses its own [schema](https://github.com/defenseunicorns/zarf/blob/master/zarf.schema.json) to define its configuration files. This schema is used to describe package configuration options and can be used to validate the configuration files before they are used to build a Zarf package.

## Adding schema validation

1. Open VS Code's `settings.json` file with `CTRL/CMD + SHIFT + P` and search for `Preferences: Open User Settings (JSON)`.
2. Add the below to your config, or modify the existing `yaml.schemas` object to include the Zarf schema.

:::note

The [YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) by RedHat is a prerequisite for this feature.

:::

```json
"yaml.schemas": {
"https://github.com/defenseunicorns/zarf/raw/master/zarf.schema.json": "zarf.yaml"
}
```

## Specifying Zarf's schema version

In some cases, it may be beneficial to lock a `zarf.yaml`'s validation to a specific version of the Zarf schema.

This can be accomplished by adding the below to the **first** line of any given `zarf.yaml`.

```yaml
# yaml-language-server: $schema=https://github.com/defenseunicorns/zarf/raw/<VERSION>/zarf.schema.json
```

Where `<VERSION>` is one of [Zarf's releases](https://github.com/defenseunicorns/zarf/releases).

0 comments on commit c7202d2

Please sign in to comment.