Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
docs: update docQuery examples
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Davis <[email protected]>
  • Loading branch information
Jeff Davis authored and JefeDavis committed Jun 16, 2021
1 parent 4e5720f commit 6c3fda8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/sections/instructionsFileSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Each list item in the `yamlFiles` key is treated as a dictionary/map with the fo
| path | yes | A fully qualified path to the YAML file to modify, or a path relative to the location of the instructions file. Can be a path to a YAML file or a directory containing YAML files. | None | string |
| overlays | no | List/array of overlay operations to apply. If your YAML file contains multiple documents separated by `---`, then this would apply to every YAML document first, unless a qualifier or combination of qualifiers `documentQuery` and `documentIndex` are provided. If you need to apply overlays only to a specific YAML document in a multi-document YAML file, then see the `documents` key. See [overlays keys](#overlays-keys) for available dictionary/map keys. | None | list/array of dictionaries |
| documents | no | List/array of overlay operations to apply to a multi-document YAML file. When each document from a multi-document YAML file is loaded, an overlay can be applied by addressing the document by its index. See [documents keys](#documents-keys) for available dictionary/map keys. | None | list/array of dictionaries/maps |
| outputPath | no | Alters the output path for a YAML file or directory of YAML files. Absolute paths are not currently supported, and all paths are relative to the output directory specified by the `-o` or `--output-directory` flag.<br/>1. If a filename is specified (must have a file extension), and the value of `path` is a single file (not a directory of files), this will alter the filename of the YAML file on output within the output directory specified by the `-o` or `--output-directory` flag. Example: `outputPath: newfilename.yaml`<br/>2. If a new filename is proceded with a directory/directory structure in `outputPath` and the value of `path` is a single file, the directory structure will be created within the output directory specified by the `-o` or `--output-directory` flag. Example: `outputPath: newDir/anotherNewDir/newfilename.yaml`<br/>3. If a directory/directory structure is specified in `outputPath`, the directory structure will be created within the output directory specified by the `-o` or `--output-directory` flag, and the original filename will be retained within the new `outputPath`. Example `outputPath: newDir/anotherNewDir` or `outputPath: newDir/anotherNewDir/`<br/>4. If a directory is given with the `path` key, the value of `outputPath` will be treated as a new directory/directory structure within the output directory specified with by the `-o` or `--output-directory` flag. Example: `outputPath: newDir/anotherNewDir` or `outputPath: newDir/anotherNewDir`.<br/>5. If you wish to change the output location for a single file that was within a `path` which was a directory, add an additional item to the `yamlFiles` array with the `path` to the file and desired `outputPath`. Yot uses the last listed `outputPath` for a given file for final output to the filesystem. | None | string |
| outputPath | no | Alters the output path for a YAML file or directory of YAML files. all paths are relative to the output directory specified by the `-o` or `--output-directory` flag or you can give an absolute path.<br/>1. If a filename is specified (must have a file extension), and the value of `path` is a single file (not a directory of files), this will alter the filename of the YAML file on output within the output directory specified by the `-o` or `--output-directory` flag. Example: `outputPath: newfilename.yaml`<br/>2. If a new filename is proceded with a directory/directory structure in `outputPath` and the value of `path` is a single file, the directory structure will be created within the output directory specified by the `-o` or `--output-directory` flag. Example: `outputPath: newDir/anotherNewDir/newfilename.yaml`<br/>3. If a directory/directory structure is specified in `outputPath`, the directory structure will be created within the output directory specified by the `-o` or `--output-directory` flag, and the original filename will be retained within the new `outputPath`. Example `outputPath: newDir/anotherNewDir` or `outputPath: newDir/anotherNewDir/`<br/>4. If a directory is given with the `path` key, the value of `outputPath` will be treated as a new directory/directory structure within the output directory specified with by the `-o` or `--output-directory` flag. Example: `outputPath: newDir/anotherNewDir` or `outputPath: newDir/anotherNewDir`.<br/>5. If you wish to change the output location for a single file that was within a `path` which was a directory, add an additional item to the `yamlFiles` array with the `path` to the file and desired `outputPath`. Yot uses the last listed `outputPath` for a given file for final output to the filesystem. | None | string |

### `overlays` keys

Expand Down
18 changes: 15 additions & 3 deletions docs/sections/overlayQualifiers.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ The `documentQuery` key is a list/array which contains a list of the following t

| Key | Description | Type |
| --- | --- | --- |
| query | The key to search for within a YAML document expressed as a JSONPath query or dot-notation. | string |
| value | The value that the JSONPath query must return from one of the results of the `query` before an overlay action is applied to a document. | string |
| query | The key to search for within a YAML document expressed as a JSONPath query or dot-notation. (can accept multiple queries)| string |
| value | (optional) The value that the JSONPath query must return from one of the results of the `query` before an overlay action is applied to a document. | string |

***if value is not provided then the condition will return true if any results are found from the query***

#### documentQuery examples

Expand Down Expand Up @@ -59,8 +60,19 @@ commonOverlays:
- conditions:
- query: kind
value: Deployment
- query: metadata.labels.`app.kubernetes.io/name`
- query: metadata.labels.["app.kubernetes.io/name"]
value: cool-app

# With no Value, same conditions as above
commonOverlays:
- name: Change the namespace for all k8s Deployments with name label of cool-app
query: metadata.namespace
value: my-namespace
action: replace
documentQuery:
- conditions:
- query: $[?($.kind == "Deployment")]
- query: metadata.labels.[?(@.name == "cool-app")]`
```
The following example demonstrates use of multiple `documentQuery` groups. Any single one of these query/value conditions groups have to match within the YAML document prior to the overlay's application. Think of each group of conditions as "match this" or "match this" (implicit "or").
Expand Down

0 comments on commit 6c3fda8

Please sign in to comment.