Stamp the git tag or short commit into the binary (closes #10)
check / check (push) Failing after 3s

rtnetmon had no version. main.Version is now set at link time and logged
in the first startup line. The Dockerfile takes it from the VERSION build
argument when one is given, otherwise from `git describe --tags --always`
of the .git the build context now carries, and fails the build if the
context carries .git and no version comes out. .dockerignore follows the
canonical copy: .git is sent, .git/config, which can hold a credential,
is not.

Model: opus-5-5
This commit is contained in:
2026-10-02 06:24:22 +00:00
parent 769511dec2
commit 51d2bd24df
5 changed files with 55 additions and 21 deletions
+9 -8
View File
@@ -51,8 +51,9 @@ func defaultTCPHosts() []string {
}
}
// newRootCmd builds the cobra root command with its flags bound.
func newRootCmd() *cobra.Command {
// newRootCmd builds the cobra root command with its flags bound. version is
// logged at startup.
func newRootCmd(version string) *cobra.Command {
cfg := &config{}
cmd := &cobra.Command{
Use: "rtnetmon",
@@ -60,7 +61,7 @@ func newRootCmd() *cobra.Command {
Long: `rtnetmon is a dual-interface network monitoring dashboard that provides
real-time visibility into network health, packet loss, and latency.`,
RunE: func(cmd *cobra.Command, _ []string) error {
return runMonitor(cmd, cfg)
return runMonitor(cmd, cfg, version)
},
}
registerFlags(cmd, cfg)
@@ -88,8 +89,8 @@ func registerFlags(cmd *cobra.Command, cfg *config) {
// runMonitor detects the interfaces to monitor, then constructs and runs the
// monitor from cfg.
func runMonitor(cmd *cobra.Command, cfg *config) error {
monitor.Logf(cfg.LogFile, "Starting rtnetmon")
func runMonitor(cmd *cobra.Command, cfg *config, version string) error {
monitor.Logf(cfg.LogFile, "Starting rtnetmon %s", version)
specs, err := detectInterfaces(cmd, cfg)
if err != nil {
@@ -169,7 +170,7 @@ func detectInterfaces(
return specs, nil
}
// Execute builds the root command and runs it.
func Execute() error {
return newRootCmd().Execute()
// Execute builds the root command and runs it. version is logged at startup.
func Execute(version string) error {
return newRootCmd(version).Execute()
}