Skip to content

Commit 520045f

Browse files
author
Kevin Paulisse
committed
Add documentation for catalog validation
1 parent b5979a6 commit 520045f

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

doc/advanced-catalog-validation.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Catalog validation
2+
3+
`octocatalog-diff` contains additional functionality to validate catalogs, based on configurable criteria.
4+
5+
Catalog validation features include:
6+
7+
- Validate references: Ensure resources targeted by `before`, `notify`, `require`, and/or `subscribe` exist in the catalog
8+
9+
## Validate references
10+
11+
`octocatalog-diff` includes the ability to validate references by ensuring resources targeted by `before`, `notify`, `require`, and/or `subscribe` parameters also exist in the catalog.
12+
13+
Consider the following Puppet code:
14+
15+
```
16+
file { '/usr/local/bin/some-script.sh':
17+
source => 'puppet:///modules/test/usr/local/bin/some-script.sh',
18+
notify => Exec['execute /usr/local/bin/some-script.sh'],
19+
}
20+
```
21+
22+
The catalog for this code would build, whether or not the `exec { 'execute /usr/local/bin/some-script.sh': ... }` resource was part of the catalog. However, when the catalog is applied on the Puppet agent, it would fail if this resource is missing.
23+
24+
With the `--validate-references` command line flag (or the `settings[:validate_references]` [configuration setting](/doc/configuration.md), you can instruct `octocatalog-diff` to confirm that any resource targeted by a `before`, `notify`, `require`, and `subscribe` parameter actually exists. If the resource is missing from the catalog, an error will be raised, just as if the catalog failed to compile.
25+
26+
The command line argument is demonstrated here:
27+
28+
```
29+
# Validate all references: before,notify,require,subscribe
30+
octocatalog-diff ... --validate-references before,notify,require,subscribe
31+
32+
# Validate some references: only before and require
33+
octocatalog-diff ... --validate-references before,require
34+
35+
# Validate no references
36+
octocatalog-diff ... --no-validate-references
37+
```
38+
39+
By default, no references are validated.
40+
41+
Note as well, when using `octocatalog-diff` to compare two catalogs, the references in the "from" catalog are not checked. The reason for this design decision is as follows: the "from" catalog is generally what is considered to be stable and is perhaps already deployed, so it adds no value (and perhaps inhibits the ability to develop further) if `octocatalog-diff` fails just because references in the "from" catalog are broken.

doc/advanced.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ See also:
2121
- [Overriding facts](/doc/advanced-override-facts.md)
2222
- [Puppet Enterprise node classification service](/doc/advanced-pe-enc.md)
2323
- [Using `octocatalog-diff` without git](/doc/advanced-using-without-git.md)
24+
- [Catalog validation](/doc/advanced-catalog-validation.md)
2425

2526
### Controlling output
2627

0 commit comments

Comments
 (0)