relgap drift
Scans each root for repositories the way 'relgap pins' does and prints a matrix with a row per repository and a column per tool that drifts. A tool drifts when its pins stand for more than one version across the scanned repositories. It reads files only and makes no network calls unless --latest is set.
An exact pin counts as its version. A value marked ≈ allows more than one version. A constraint (~> 1.15) counts as the highest exact pin of the tool in the same repository that satisfies it, otherwise as its lower bound (1.15.0). Prefix (26) and channel (latest) pins aren't compared. --drift-ignore-constraints leaves constraint pins out of the comparison too. A version marked * differs from the version most repositories pin.
--from-tfcensus reads the JSON of 'tfcensus inventory --format json' (schema_version 1) instead of scanning, or as well when roots are given. Each unit and workspace becomes a row named repo/path, with :workspace for a workspace other than default. The version that last wrote the unit's state is an exact terraform pin, or opentofu when tfcensus says OpenTofu applied it, and each provider version from the unit's lock file is an exact tfprovider pin. Units without a version add no pins. The inventory's errors make the report partial. An inventory from another tool or schema version exits 2. - reads it from stdin.
Tools that agree everywhere, or that only one repository pins, are listed below the matrix. --tool limits the report to the named tools and gives each one a column, even when it doesn't drift. Ignore rules in the config drop matching pins.
--latest adds a latest row with the newest stable version of each tool, from GraphQL queries of 10 to 25 tools, sent in parallel.
--format sarif writes a SARIF 2.1.0 log for GitHub code scanning with a result per drifted pin (a compared pin whose version differs from the version most repositories pin, the cells marked *), at the pin's file and line, and a failed result per file that doesn't parse or tool whose latest version can't be listed.
--fail-on drift counts the drifted pins and exits 3 once the count reaches --min-count (default 1). Otherwise a file that doesn't parse, or a tool whose latest version can't be listed, exits 1 after printing the rest.
Roots default to scan.roots, then the current directory, unless --from-tfcensus is set.
Usage
relgap drift [roots...] [flags]Arguments
| Argument | Required | Repeatable |
|---|---|---|
roots | no | yes |
Flags
| Flag | Description | Type | Default | Values | Config key | Notes |
|---|---|---|---|---|---|---|
--drift-ignore-constraints | compare exact pins only; constraint pins are shown but don't count | bool | ||||
--fail-on | exit 3 when this matches: drift; repeatable (config policy.fail_on) | list, repeatable | drift: repositories pin different versions | policy.fail_on | ||
--from-tfcensus | add the units of this tfcensus inventory JSON as rows (- for stdin); without roots, scan nothing | string | ||||
--latest | add the newest stable version of each tool (needs the network or the cache) | bool | ||||
--md-max-chars | cut Markdown output to this many characters at a row or section boundary; 0 means no limit | int | 60000 | |||
--min-count | findings a --fail-on value needs before it exits 3 | int | 1 | |||
--out | also write the report to a file as format=path (repeatable); format is one of plain, md, json, sarif or github | string, repeatable | plain: table without colormd: Markdownjson: JSON envelope for scriptssarif: SARIF 2.1.0 for code scanninggithub: GitHub Actions annotations | |||
--submodules | scan checked-out git submodules as repositories | bool | ||||
--tool | report only this tool, with a column even when it agrees; repeatable | list, repeatable |
The global flags work with every command.
Output formats
--format accepts tty, plain, md, json, sarif, github. Without it, the format is tty when stdout is a terminal and plain otherwise. Formats are described on the global flags page.
Fail-on values
--fail-on makes the command exit 3 when the report has a match:
| Value | Matches |
|---|---|
drift | repositories pin different versions |
Exit codes
| Code | Meaning |
|---|---|
| 0 | The command finished. With --fail-on, nothing matched. |
| 1 | The command failed: a read, a write, a child process or a check failed. |
| 2 | Wrong usage: an unknown command or flag, a bad value or argument, an invalid config file, or a prompt with no terminal. |
| 3 | A --fail-on gate matched. The report is still written. |
| 4 | Credentials were missing or rejected for every source the command needed. |
| 130 | Interrupted by Ctrl-C (SIGINT) or a cancelled context. |
All codes are listed on the exit codes page.
Examples
relgap drift ~/src/infra
tfcensus inventory ~/src/infra/* --format json | relgap drift --from-tfcensus -
relgap drift ~/src/infra --from-tfcensus inventory.json --tool terraform
relgap drift ~/src/infra --tool terraform --tool terragrunt
relgap drift ~/src/infra ~/src/apps --latest --format md
relgap drift --fail-on drift --drift-ignore-constraints
relgap drift ~/src/infra --fail-on drift --min-count 3 --format sarif > drift.sarif