Stamp the git tag or short commit into the binary (closes #10)
check / check (push) Failing after 2s
check / check (push) Failing after 2s
rtnetmon had no version. main.Version is now set at link time and logged in the first startup line. `make build` and `make dev` set it from `git describe --tags --always` unless VERSION is given. 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:
@@ -3,4 +3,4 @@ package cli
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
// NewRootCmd exposes newRootCmd for external tests.
|
||||
func NewRootCmd() *cobra.Command { return newRootCmd() }
|
||||
func NewRootCmd() *cobra.Command { return newRootCmd("dev") }
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user