You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(config): rename default config to .oasdiff.*; add --config flag and OASDIFF_CONFIG env var
Switch the default config-file lookup from oasdiff.{json,yaml,yml,toml,hcl}
to .oasdiff.{json,yaml,yml,toml,hcl}. The dotfile convention matches the
overwhelming pattern for CI/lint tools (.eslintrc, .prettierrc,
.golangci.yml, .yamllint, .flake8, .markdownlint.json) — putting
oasdiff.yaml at the root reads as a project-defining file, which oasdiff
isn't.
For backward compatibility with existing CLI users who relied on the old
filename, two new override mechanisms:
- --config <path> persistent flag on the root command
- OASDIFF_CONFIG environment variable
Precedence: --config > OASDIFF_CONFIG > default .oasdiff.* lookup. When
either override is set, the file MUST exist (missing or malformed file is
an error, unlike the silent-skip semantics of the default lookup).
The env var earns its place specifically for CI workflows: a customer
with multiple oasdiff invocations in one workflow sets OASDIFF_CONFIG
once at the workflow's env: block instead of duplicating --config per
step. This matches industry convention (KUBECONFIG, AWS_CONFIG_FILE,
DOCKER_CONFIG, NPM_CONFIG_USERCONFIG).
Migration for existing oasdiff.yaml users: rename to .oasdiff.yaml,
OR pass --config oasdiff.yaml (or set OASDIFF_CONFIG=oasdiff.yaml).
Tests: 7 new cases in internal/viper_test.go cover the default lookup,
legacy-filename ignored, missing-config-not-an-error, --config explicit
path, --config missing file is an error, --config overrides default,
OASDIFF_CONFIG env var, and --config wins over OASDIFF_CONFIG.
Copy file name to clipboardExpand all lines: docs/CONFIG-FILES.md
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,27 @@
1
1
# Configuration Files
2
2
The `oasdiff` command can read its configuration from a file.
3
-
This is useful for complex configurations or repeated usage patterns.
4
-
The config file should be named oasdiff.{json,yaml,yml,toml,hcl} and placed in the directory where the command is run.
5
-
For example, see [oasdiff.yaml](../examples/oasdiff.yaml).
3
+
This is useful for complex configurations or repeated usage patterns.
4
+
5
+
## Default lookup
6
+
7
+
By default, `oasdiff` looks for `.oasdiff.{json,yaml,yml,toml,hcl}` in the directory where the command is run.
8
+
9
+
For example, see [.oasdiff.yaml](../examples/.oasdiff.yaml).
10
+
11
+
## Explicit override
12
+
13
+
To use a different filename or path, pass `--config <path>` or set the `OASDIFF_CONFIG` environment variable. When either is set, the default lookup is skipped and the file at the given path must exist (missing or malformed file is an error).
require.EqualError(t, internal.RunViper(&cmd, v), "failed to load config file: validation error: decoding failed due to the following error(s):\n\n'internal.Config' has invalid keys: invalid")
0 commit comments