Skip to content

Feat: Make cli argument vars to be slice of string#1024

Open
Lirt wants to merge 1 commit into
goss-org:masterfrom
Lirt:args/varsfile-slice
Open

Feat: Make cli argument vars to be slice of string#1024
Lirt wants to merge 1 commit into
goss-org:masterfrom
Lirt:args/varsfile-slice

Conversation

@Lirt

@Lirt Lirt commented May 9, 2025

Copy link
Copy Markdown

This change allows passing multiple variables files as input to CLI. Order of files is important as overlapped non-empty keys in yaml or json files will be overwritten by subsequent file.

This change is backwards compatible because CLI library implements slice definition as repetition of the --vars argument. Using goss with single file produces the same outputs with the code change as it was before.

Usage:

./goss --vars file1.yaml --vars file2.yaml validate
Checklist

make test-all doesn't exist anymore. Probably should be make test-int-all. make test passes correctly.

  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

Closes #1023


📚 Documentation preview 📚: https://goss--1024.org.readthedocs.build/en/1024/

@Lirt
Lirt requested a review from aelsabbahy as a code owner May 9, 2025 12:24
@Lirt
Lirt force-pushed the args/varsfile-slice branch 2 times, most recently from ffcaea0 to 3819332 Compare May 9, 2025 12:35
@Lirt

Lirt commented Jul 1, 2025

Copy link
Copy Markdown
Author

Hello @aelsabbahy,

any time expectation when you could look at this change?

@Lirt

Lirt commented Aug 29, 2025

Copy link
Copy Markdown
Author

Ping for visibility. If there is low amount of maintainers, I can offer my help.

uk-bolly added a commit to uk-bolly/bolly_goss that referenced this pull request Jun 24, 2026
Taken changes and issues from upstream and incorporated
Fixed other issues around some integration tests
workflow actions updated

### PRs Incorporated

- Thanks to [@kgaughan](https://github.com/kgaughan) for authoring the `urfave/cli` v3 migration
  - [#1060](goss-org/goss#1060) - CLI migrated from `urfave/cli` v1 to `urfave/cli/v3` v3.9.0; v3 is actively maintained and drops transitive dependencies (`go-md2man`, `blackfriday`)
- Thanks to [@kgaughan](https://github.com/kgaughan) for restoring clearer `ContainElements` matcher error messages
  - [#1067](goss-org/goss#1067) - pre-validates array/slice/map types before delegating to gomega, restoring the pre-iterator error text forinvalid inputs (e.g. strings)
- Thanks to [@kgaughan](https://github.com/kgaughan) for the dependency and tooling refresh
  - [#1064](goss-org/goss#1064) - golangci-lint v2.12.2 config (staticcheck settings, `noinlineerr` disabled), dependency bumps (`gomega` v1.41.0, `prometheus/common` v0.68.1), Trivy action updates, and minor lint cleanups; fork already had most workflow, Dockerfile, and code changes at equal or newer versions

### Security
- CLI announce output logs resource type and ID only; no longer marshals and prints full resource JSON (fixes CodeQL clear-text logging of password and other sensitive fields)
- Health probe debug logging records HTTP status only; no longer logs response body on non-OK status (avoids clear-text logging of password and other sensitive fields from test output)
- Health probe content negotiation errors no longer log the raw `Accept` header value from untrusted requests

### Fixed
- Integration test `add.goss.yaml` expectations updated for announce output change (resource type and ID only, not full marshaled YAML)
- `bullseye` apache2 version bumped to `2.4.67-1~deb11u3` in `vars.yaml` (Debian security update)
- Integration test fixtures: removed duplicate `service: apache2` / `service: httpd` definitions between `goss-shared.yaml` and `goss-service.yaml`; eliminates duplicate-key warnings during `validate` in CI

### Added
- Multiple `--vars` files supported; vars are merged in flag order with later files overriding overlapping keys; `--vars-inline` still applies last ([#1023](goss-org/goss#1023); thanks to [@Lirt](https://github.com/Lirt) for [PR #1024](goss-org/goss#1024))
uk-bolly added a commit to uk-bolly/bolly_goss that referenced this pull request Jun 25, 2026
Taken changes and issues from upstream and incorporated
Fixed other issues around some integration tests
workflow actions updated

### PRs Incorporated

- Thanks to [@kgaughan](https://github.com/kgaughan) for authoring the `urfave/cli` v3 migration
  - [#1060](goss-org/goss#1060) - CLI migrated from `urfave/cli` v1 to `urfave/cli/v3` v3.9.0; v3 is actively maintained and drops transitive dependencies (`go-md2man`, `blackfriday`)
- Thanks to [@kgaughan](https://github.com/kgaughan) for restoring clearer `ContainElements` matcher error messages
  - [#1067](goss-org/goss#1067) - pre-validates array/slice/map types before delegating to gomega, restoring the pre-iterator error text forinvalid inputs (e.g. strings)
- Thanks to [@kgaughan](https://github.com/kgaughan) for the dependency and tooling refresh
  - [#1064](goss-org/goss#1064) - golangci-lint v2.12.2 config (staticcheck settings, `noinlineerr` disabled), dependency bumps (`gomega` v1.41.0, `prometheus/common` v0.68.1), Trivy action updates, and minor lint cleanups; fork already had most workflow, Dockerfile, and code changes at equal or newer versions

### Security
- CLI announce output logs resource type and ID only; no longer marshals and prints full resource JSON (fixes CodeQL clear-text logging of password and other sensitive fields)
- Health probe debug logging records HTTP status only; no longer logs response body on non-OK status (avoids clear-text logging of password and other sensitive fields from test output)
- Health probe content negotiation errors no longer log the raw `Accept` header value from untrusted requests

### Fixed
- Integration test `add.goss.yaml` expectations updated for announce output change (resource type and ID only, not full marshaled YAML)
- `bullseye` apache2 version bumped to `2.4.67-1~deb11u3` in `vars.yaml` (Debian security update)
- Integration test fixtures: removed duplicate `service: apache2` / `service: httpd` definitions between `goss-shared.yaml` and `goss-service.yaml`; eliminates duplicate-key warnings during `validate` in CI

### Added
- Multiple `--vars` files supported; vars are merged in flag order with later files overriding overlapping keys; `--vars-inline` still applies last ([#1023](goss-org/goss#1023); thanks to [@Lirt](https://github.com/Lirt) for [PR #1024](goss-org/goss#1024))
@kgaughan

Copy link
Copy Markdown
Contributor

@Lirt Could you fix the merge conflicts on this PR? I suspect that the main cause is that urfave/cli has been updated to v3.

@Lirt
Lirt force-pushed the args/varsfile-slice branch from 3819332 to 23fc438 Compare June 29, 2026 18:59
This change allows passing multiple variables files as input to
CLI. Order of files is important as overlapped non-empty keys in yaml or json
files will be overwritten by subsequent file.

This change is backwards compatible as CLI library makes the slice
definition to be repetition of the --vars argument. Using goss with
single file produces same outputs with this code change as it was before.

Usage:
```
./goss --vars file1.yaml --vars file2.yaml validate
```

Issue ref: goss-org#1023

Signed-off-by: Ondrej Vasko <ondrej.vaskoo@gmail.com>
@Lirt
Lirt force-pushed the args/varsfile-slice branch from 23fc438 to d9ef0f5 Compare June 29, 2026 19:00
@Lirt

Lirt commented Jun 29, 2026

Copy link
Copy Markdown
Author

Hello @kgaughan,

I rebased the PR. There was only small diff in the config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple vars files

2 participants