Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ gopath := $(shell go env GOPATH)
goversion := $(shell go version | cut -f3 -d' ')
goversion-required := $(shell cat .go-version)
gittag := $(shell git tag --points-at HEAD)
githash := $(shell git rev-parse --short=7 HEAD)
gitdirty := $(shell git status -s)
# don't provide the git tag if the git status is dirty.
ifneq ($(gitdirty),)
gittag :=
githash :=
endif
ldflags := '-s -w -X github.com/spiffe/spire/pkg/common/version.gittag=$(gittag)'
ldflags := '-s -w -X github.com/spiffe/spire/pkg/common/version.gittag=$(gittag) -X github.com/spiffe/spire/pkg/common/version.githash=$(githash)'

utils = github.com/spiffe/spire/tools/spire-plugingen

Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
module github.com/spiffe/spire

go 1.13
Comment thread
rturner3 marked this conversation as resolved.

replace github.com/spiffe/spire/proto/spire => ./proto/spire

require (
Expand Down
2 changes: 2 additions & 0 deletions pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (a *Agent) Run(ctx context.Context) error {
Metrics: metrics,
})

telemetry.EmitVersion(metrics)

cat, err := catalog.Load(ctx, catalog.Config{
Log: a.c.Log.WithField(telemetry.SubsystemName, telemetry.Catalog),
GlobalConfig: catalog.GlobalConfig{
Expand Down
11 changes: 11 additions & 0 deletions pkg/common/telemetry/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package telemetry

import (
"github.com/spiffe/spire/pkg/common/version"
)

func EmitVersion(m Metrics) {
m.SetGaugeWithLabels([]string{"started"}, 1, []Label{
{Name: "version", Value: version.Version()},
})
}
7 changes: 4 additions & 3 deletions pkg/common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ const (
)

var (
gittag = ""
gittag = ""
githash = "unk"
)

func Version() string {
if gittag == "" {
return fmt.Sprintf("%s-dev", Base)
return fmt.Sprintf("%s-dev-%s", Base, githash)
}
return Base
return gittag
}
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ func (s *Server) run(ctx context.Context) (err error) {
Metrics: metrics,
})

telemetry.EmitVersion(metrics)

// Create the identity provider host service. It will not be functional
// until the call to SetDeps() below. There is some tricky initialization
// stuff going on since the identity provider host service requires plugins
Expand Down
2 changes: 2 additions & 0 deletions tools/external/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ require (
github.com/pseudomuto/protokit v0.1.0 // indirect
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846 // indirect
)

go 1.13
Comment thread
rturner3 marked this conversation as resolved.