diff --git a/.goreleaser.yml b/.goreleaser.yml index fefb6d0..a264cc8 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,6 +6,7 @@ builds: - CGO_ENABLED=0 goos: - linux + - darwin main: ./cmd/main.go archive: replacements: diff --git a/cmd/main.go b/cmd/main.go index 9e1dda7..4f13d4e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -7,8 +7,11 @@ import ( "github.com/firehydrant/fhcli/pkg/cli" ) +var commit string +var version string + func main() { - app := cli.NewApp() + app := cli.NewApp(commit, version) err := app.Run(os.Args) if err != nil { diff --git a/pkg/change_events/main.go b/pkg/change_events/main.go index d9d987b..cf7f5a7 100644 --- a/pkg/change_events/main.go +++ b/pkg/change_events/main.go @@ -1,6 +1,7 @@ package events import ( + "os" "strings" "time" @@ -24,12 +25,16 @@ type ChangeEvent struct { } func NewChangeEvent() ChangeEvent { - return ChangeEvent{ + ce := ChangeEvent{ Identities: make(map[string]string), Labels: make(map[string]string), StartsAt: time.Now(), EndsAt: time.Now(), } + + ce.Labels["hostname"] = os.Getenv("HOSTNAME") + + return ce } func (ce *ChangeEvent) identitiesToAPI() []*models.PostV1ChangesEventsChangeIdentitiesItems0 { diff --git a/pkg/cli/main.go b/pkg/cli/main.go index eee2c5d..52ced11 100644 --- a/pkg/cli/main.go +++ b/pkg/cli/main.go @@ -2,6 +2,7 @@ package cli import ( "errors" + "fmt" apiclient "github.com/firehydrant/fhcli/pkg/api_client" "github.com/urfave/cli" @@ -30,7 +31,7 @@ var sharedFlags = []cli.Flag{ }, } -func NewApp() *cli.App { +func NewApp(commit string, version string) *cli.App { app := cli.NewApp() app.Flags = []cli.Flag{ @@ -70,6 +71,8 @@ func NewApp() *cli.App { }, } + app.Version = fmt.Sprintf("%s (%s)", version, commit) + return app }