-
Notifications
You must be signed in to change notification settings - Fork 0
Inject Application Version at Build Time #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1388,7 +1388,7 @@ netscan exposes HTTP health check endpoints for monitoring, container orchestrat | |
| | Field | Type | Description | | ||
| |-------|------|-------------| | ||
| | `status` | string | Overall service health: `"healthy"` (all systems operational), `"degraded"` (InfluxDB unreachable but monitoring continues), or `"unhealthy"` (critical failure) | | ||
| | `version` | string | Application version string (currently hardcoded `"1.0.0"`, TODO: inject at build time) | | ||
| | `version` | string | Application version string (injected at build time via ldflags) | | ||
| | `uptime` | string | Human-readable time since service started (e.g., `"2h15m30s"`) | | ||
|
Comment on lines
1390
to
1392
|
||
| | `device_count` | int | Total number of devices currently managed by StateManager | | ||
| | `snmp_suspended_devices` | int | Number of devices currently suspended by SNMP circuit breaker | | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -64,10 +64,10 @@ build_binary() { | |||||
|
|
||||||
| # Get version info | ||||||
| local version | ||||||
| version=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") | ||||||
| version=$(git describe --tags --always --dirty 2>/dev/null || echo "1.0.0") | ||||||
|
||||||
| version=$(git describe --tags --always --dirty 2>/dev/null || echo "1.0.0") | |
| version=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| package main | ||
| package version | ||
|
|
||
| // Version is the application version. | ||
| // It is set at build time using -ldflags. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ BINARY=netscan | |
| cd "$PROJECT_ROOT" | ||
|
|
||
| # Determine version | ||
| VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") | ||
| VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "1.0.0") | ||
| echo "Building version: $VERSION" | ||
|
Comment on lines
14
to
16
|
||
|
|
||
| # Build the binary | ||
|
|
@@ -22,6 +22,6 @@ if [ -f "$BINARY" ]; then | |
| fi | ||
|
|
||
| echo "Building netscan..." | ||
| go build -ldflags "-X main.Version=$VERSION" -o $BINARY ./cmd/netscan | ||
| go build -ldflags "-X github.com/kljama/netscan/internal/version.Version=$VERSION" -o $BINARY ./cmd/netscan | ||
|
|
||
| echo "Build complete: $BINARY" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaulting the Docker build ARG
VERSIONto1.0.0will stamp images built without an explicit--build-arg VERSION=...as1.0.0, which can be misleading in dev/CI. Consider defaulting this back todev(orunknown) and passing the real version explicitly for release builds.