Add --version option #23
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
keyop-go/nfq_forwarder#23
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We should include a '--version' command line option in order to check the current release number.
changed the description
Plan
nfq_forwardercurrently has no version string baked into the binary at all - releases are puregit tags (
vX.Y.Z), so there's nothing for a--versionflag to report yet. This plan adds one.cmd/main.go: add aversionpackage variable, defaulting to"dev"for a plaingo build/go runoutside the release pipeline..goreleaser.yaml: addldflags: - -X main.version={{ .Tag }}to thebuilds:entry, soevery snapshot (
make build/make package) and released (make release, CI tag pipeline)binary is stamped with the exact git tag it was built from (e.g.
v1.0.2) - matching how thisproject already refers to releases everywhere else (git tag, GitLab Release page URL).
cmd/setup.NewApp: takes a newversion stringparameter, passed through fromcmd/main.go.--versionflag (cmd/setup/setup.go'sappFlags()): a plain boolean flag with noshort alias -
-vis already--verbosein this CLI, andurfave/cli's own built-in--version/-vauto-injected flag would collide with that. Checked first, beforeresolveConfiguration, inNewApp'sAction- works regardless of--config/any other flag,and does no iptables/capability/netlink work: prints
nfq_forwarder <version>and exitssuccessfully.
appFlags()gains a check that theversionflag exists with no alias (matchingthe existing per-flag tests already in
cmd/setup's test file); the version-string formattingis extracted into a small, directly-testable function.
NewApp(...).Run(...)itself staysuntested, consistent with the rest of this package (its
Actionalways eventually reachesnfq_forwarder.NFQForwarderMain, which performs real system work and must never run in atest).
Work is happening on branch
issue23_version_option; an MR will follow referencing this issue.mentioned in commit
5809daf6e4mentioned in merge request !64
mentioned in commit
afe0c4e4a4MR is approved and merged, and appears to do what has been requested. Separately asked Claude to ensure that non-tagged releases should be given a version of
vX.Y.Z-dev-<commit>where X.Y.Z is the most recent tag, andcommitis the abbreviated latest git release on the branch. This also works correctly.v1.0.3. is being released now - closing this ticket.