Skip to content

feat: use build-time ldflags for Version() string#29

Merged
msutara merged 1 commit intomainfrom
fix/version-ldflags
Mar 22, 2026
Merged

feat: use build-time ldflags for Version() string#29
msutara merged 1 commit intomainfrom
fix/version-ldflags

Conversation

@msutara
Copy link
Copy Markdown
Owner

@msutara msutara commented Mar 22, 2026

Summary

Replace hard-coded version string with a package-level var version = "dev" that gets set via -X linker flag at build time from the core binary's Makefile and release workflow.

Changes

  • plugin.go: Added var version = "dev" at package scope; Version() now returns it instead of hard-coded "0.4.3"

How It Works

When core builds the cm binary, it passes:
-X github.com/msutara/cm-plugin-network.version=0.4.5

This sets the unexported version var at link time. Without the flag, it defaults to "dev" for local development.

Testing

  • go build ./... pass
  • go test ./... -count=1 pass (metadata test checks non-empty, not specific value)
  • golangci-lint run pass

Related to msutara/config-manager-core#86

Replace hard-coded version with package-level var set via -X linker
flag at build time. Defaults to 'dev' for local development.

Related to msutara/config-manager-core#86

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 22, 2026 16:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the network plugin’s reported version to be injected at build time (via Go -ldflags -X) instead of being hard-coded in the plugin, aligning the plugin’s Version() with how the core binary is built/released.

Changes:

  • Introduces a package-level var version = "dev" intended to be overridden at link time.
  • Updates (*NetworkPlugin).Version() to return the version variable instead of a fixed string.

@msutara msutara merged commit 2d96fc6 into main Mar 22, 2026
7 checks passed
@msutara msutara deleted the fix/version-ldflags branch March 22, 2026 16:34
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.

2 participants