|
| 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. |
0 commit comments