Relocate packaging: RPM, shell completions, no-TTY fix, repaired tests #13

Merged
benvin merged 1 commits from benvin/relocate-package-completions into main 2026-07-05 00:02:34 +10:00
Owner

Why

The unit tests stopped compiling after the --pm-p/-i match-modifier refactor was left uncommitted, there was no RPM/completions distribution story, and invoking the tool without a TTY against an empty pipe silently returned nothing. This makes the project releasable and safe to run from agents/CI.

Changes

  • Make stdin handling robust: replace the fragile !isTerminal check with stdinReader(), which only reads node names when stdin is a real pipe/redirect carrying data. Terminals, /dev/null, and empty/closed pipes now fall through to a normal query, so running without a TTY behaves like an interactive run.
  • Repair and expand main_test.go to match the current buildQuery/run signatures; add coverage for the match modifiers, all output modes, config precedence, and the new stdinReader logic. httptest stubs PuppetDB (no live deps).
  • Add nfpm packaging (packaging/nfpm.yaml, scripts/build-rpm.sh): installs the binary to /usr/bin/node-lookup and bundles generated bash/zsh/fish completions under the standard system paths.
  • Rework the Makefile to build into dist/ and add completions/rpm targets.
  • Split PR CI into build, test, and pre-commit workflows and extend release to build the RPM and PUT it to the artifactapi rpm-internal repo. Every step sets a serviceAccount and k8s resources.

The project directory has also been relocated under prodenv.

## Why The unit tests stopped compiling after the `--pm` → `-p`/`-i` match-modifier refactor was left uncommitted, there was no RPM/completions distribution story, and invoking the tool without a TTY against an empty pipe silently returned nothing. This makes the project releasable and safe to run from agents/CI. ## Changes - Make stdin handling robust: replace the fragile `!isTerminal` check with `stdinReader()`, which only reads node names when stdin is a real pipe/redirect carrying data. Terminals, `/dev/null`, and empty/closed pipes now fall through to a normal query, so running without a TTY behaves like an interactive run. - Repair and expand `main_test.go` to match the current `buildQuery`/`run` signatures; add coverage for the match modifiers, all output modes, config precedence, and the new `stdinReader` logic. `httptest` stubs PuppetDB (no live deps). - Add nfpm packaging (`packaging/nfpm.yaml`, `scripts/build-rpm.sh`): installs the binary to `/usr/bin/node-lookup` and bundles generated bash/zsh/fish completions under the standard system paths. - Rework the Makefile to build into `dist/` and add `completions`/`rpm` targets. - Split PR CI into `build`, `test`, and `pre-commit` workflows and extend `release` to build the RPM and `PUT` it to the artifactapi `rpm-internal` repo. Every step sets a `serviceAccount` and k8s resources. The project directory has also been relocated under `prodenv`.
unkinben added 1 commit 2026-07-04 22:50:14 +10:00
Package as RPM, add completions, fix no-TTY behavior, repair tests
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ea5c43468f
The test suite no longer compiled after the -p/-i match-modifier refactor,
there was no RPM packaging or shell-completion story, and running without a
TTY against an empty pipe silently returned nothing.

- Replace the fragile !isTerminal stdin check with stdinReader(): only read
  node names when stdin is a real pipe/redirect carrying data, so /dev/null,
  terminals, and empty/closed pipes fall through to a normal query (works when
  invoked by an agent/CI with no TTY).
- Rewrite main_test.go to match the current buildQuery/run signatures and add
  coverage for match modifiers, output modes, config precedence, and the new
  stdinReader logic.
- Add nfpm packaging (packaging/nfpm.yaml, scripts/build-rpm.sh) that installs
  the binary to /usr/bin and bundles generated bash/zsh/fish completions.
- Rework the Makefile to build into dist/ and add completions/rpm targets.
- Split the PR CI into build + test + pre-commit workflows and extend release
  to build the RPM and PUT it to the artifactapi rpm-internal repo; every step
  now sets a serviceAccount and k8s resources.
benvin merged commit e070357d3f into main 2026-07-05 00:02:34 +10:00
benvin deleted branch benvin/relocate-package-completions 2026-07-05 00:02:34 +10:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unkin/node-lookup#13