Skip to content

Commit

Permalink
feat: binaries know their build date and commit hash
Browse files Browse the repository at this point in the history
Will be used for a future metric reporting exporter infos.
  • Loading branch information
npdgm committed Sep 19, 2022
1 parent 06d52fc commit e5ff47e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Expand Up @@ -19,8 +19,11 @@ ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}

ARG VERSION="0.0.0"

RUN go build -tags netgo,osusergo -ldflags "-X \"github.com/enix/x509-certificate-exporter/v3/internal.Version=${VERSION}\"" ./cmd/x509-certificate-exporter
-tags netgo,osusergo \
-ldflags "-X \"github.com/enix/x509-certificate-exporter/v3/internal.Version=${VERSION}\" \
-X \"github.com/enix/x509-certificate-exporter/v3/internal.CommitHash=${VCS_REF}\" \
-X \"github.com/enix/x509-certificate-exporter/v3/internal.BuildDateTime=$(date -u -Iseconds)\"" \
./cmd/x509-certificate-exporter


## Production Stage
Expand Down
2 changes: 1 addition & 1 deletion cmd/x509-certificate-exporter/main.go
Expand Up @@ -109,7 +109,7 @@ func main() {
}
}

log.Infof("starting %s version %s", path.Base(os.Args[0]), internal.Version)
log.Infof("starting %s version %s (%s) (%s)", path.Base(os.Args[0]), internal.Version, internal.CommitHash, internal.BuildDateTime)
rand.Seed(time.Now().UnixNano())
exporter.ListenAndServe()
}
4 changes: 3 additions & 1 deletion internal/version.go
@@ -1,4 +1,6 @@
package internal

// Version is the exporter semantic version and is set at link time
// Version and build informations set at link time
var Version = "0.0.0"
var CommitHash = ""
var BuildDateTime = ""

0 comments on commit e5ff47e

Please sign in to comment.