Skip to content

Commit eb54b88

Browse files
committed
docs: add dropins to prose documentation
This change explains how to use the dropins and updates the local-dev config to do so. Closes: #1783 Signed-off-by: Hank Donnay <[email protected]>
1 parent 6969e00 commit eb54b88

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

Documentation/reference/config.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
## CLI Flags And Environment Variables
44

5-
Clair is configured by a structured yaml file.
6-
Each Clair node needs to specify what mode it will run in and a path to a
7-
configuration file via CLI flags or environment variables.
5+
Clair is configured by a structured yaml or JSON[^1] file and an optional directory of "merge" and "patch" documents[^1].
6+
Each Clair node needs to specify what mode it will run in and a path to a configuration file via CLI flags or environment variables.
87

98
For example:
109
```shell
@@ -28,8 +27,7 @@ $ clair -conf ./path/to/config.yaml -mode matcher
2827
```
2928

3029
The above example starts two Clair nodes using the same configuration.
31-
One will only run the indexing facilities while the other will only run the
32-
matching facilities.
30+
One will only run the indexing facilities while the other will only run the matching facilities.
3331

3432
Environment variables respected by the Go standard library can be specified
3533
if needed. Some notable examples:
@@ -41,10 +39,34 @@ if needed. Some notable examples:
4139
If running in "combo" mode you **must** supply the `indexer`, `matcher`,
4240
and `notifier` configuration blocks in the configuration.
4341

42+
## Configuration dropins
43+
44+
Starting in Clair version `4.7.0`, dropin configuration files are supported.
45+
46+
Given a root configurtaion file of `/etc/clair/config.json`, all files matching the globs `/etc/clair/config.json.d/*.json` and `/etc/clair/config.json.d/*.json-patch` would be loaded in lexical order after the root configuration file.
47+
Similarly, given `/etc/clair/config.yaml`, all files matching the globs `/etc/clair/config.yaml.d/*.yaml` and `/etc/clair/config.yaml.d/*.yaml-patch` would be loaded.
48+
Only the extensions `yaml` and `json` are supported, and indicate yaml and JSON formatting, respectively.
49+
50+
The dropin files must have the same extension and format as the root file.
51+
Dropins with the bare suffix are treated as [merge documents](rfc7386).
52+
Dropins with the `-patch` suffix are treated as [patch documents](rfc6902) and must contain a valid [RFC 6902](rfc6902) structure.
53+
Yaml documents must be resolvable to the JSON subset.
54+
55+
Take care with the [merge](rfc7386) behavior around lists; a patch operation may be more suitable.
56+
The `clairctl check-config` command can be used to ensure a merged configuration is what is intended.
57+
In addition, placing `test` operations in a patch file that's evaluated last (such as `zz-validate.json-patch`) can be used to have Clair refuse to start if some configuration values are not what is intended.
58+
59+
The application defaults are applied *after* the configuration is loaded and as such, not reflected in the `clairctl check-config` command.
60+
The output of that command is also not currently suitable to be used to "compile" a config to a single file.
61+
62+
[rfc7386]: https://datatracker.ietf.org/doc/html/rfc7386
63+
[rfc6902]: https://datatracker.ietf.org/doc/html/rfc6902
64+
4465
## Configuration Reference
4566

46-
Please see the [go module documentation][godoc_config] for additional
47-
documentation on defaults and use.
67+
Please see the [go module documentation][godoc_config] for additional documentation on defaults and use.
68+
Starting in version `4.7.0`, unknown keys are disallowed.
69+
Configurations that looked valid previously and loaded fine may now cause Clair to refuse to start.
4870

4971
[godoc_config]: https://pkg.go.dev/github.com/quay/clair/config
5072

@@ -633,3 +655,7 @@ Configuration for a prometheus metrics exporter.
633655
a string value
634656

635657
Defines the path where metrics will be served.
658+
659+
* * *
660+
661+
[^1]: Support added in version `4.7.0`.

docker-compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ x-anchors:
2121
clair-database:
2222
condition: service_healthy
2323
volumes:
24-
- "./local-dev/clair/${CLAIR_CONFIG:-config.yaml}:/etc/clair.yaml:ro"
24+
- "./local-dev/clair:/etc/clair:ro"
2525
- ".:/src"
2626
# Can't specify the config via environment because maps are not recursively
2727
# merged.
@@ -30,7 +30,7 @@ x-anchors:
3030
- run
3131
- .
3232
- -conf
33-
- /etc/clair.yaml
33+
- /etc/clair/${CLAIR_CONFIG:-config.yaml}
3434
restart: unless-stopped
3535
working_dir: /src/cmd/clair
3636

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*
2+
!.gitignore

0 commit comments

Comments
 (0)