Skip to content

Commit

Permalink
Release for MacOS, embed version and include hostname in labels
Browse files Browse the repository at this point in the history
  • Loading branch information
dcondomitti committed Feb 14, 2019
1 parent 8bf9f7f commit 8acc5c9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ builds:
- CGO_ENABLED=0
goos:
- linux
- darwin
main: ./cmd/main.go
archive:
replacements:
Expand Down
5 changes: 4 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 6 additions & 1 deletion pkg/change_events/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package events

import (
"os"
"strings"
"time"

Expand All @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"errors"
"fmt"

apiclient "github.com/firehydrant/fhcli/pkg/api_client"
"github.com/urfave/cli"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -70,6 +71,8 @@ func NewApp() *cli.App {
},
}

app.Version = fmt.Sprintf("%s (%s)", version, commit)

return app
}

Expand Down

0 comments on commit 8acc5c9

Please sign in to comment.