store and report git info

This commit is contained in:
Stephen McQuay 2018-03-08 16:16:14 -08:00
parent 56bd8445a4
commit bcbbe000f3
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5
3 changed files with 5 additions and 0 deletions

View File

@ -27,6 +27,7 @@ func main() {
r := hw.V{
Hostname: hn,
V: hw.Version,
G: hw.Git,
}
if err := json.NewEncoder(w).Encode(r); err != nil {
log.Printf("json: %+v", err)

View File

@ -20,6 +20,7 @@ var success *prometheus.CounterVec
type state struct {
Hostname string `json:"hostname"`
V string `json:"version"`
G string `json:"git"`
sync.RWMutex
Counts map[string]int `json:"counts"`
@ -84,6 +85,7 @@ func main() {
fetcher := state{
Hostname: hn,
V: hw.Version,
G: hw.Git,
Counts: map[string]int{},
}
go fetcher.update(target)

2
hw.go
View File

@ -3,6 +3,7 @@ package hw
import "net/http"
var Version = "unset"
var Git = "unset"
// OK simply return 200
func OK(w http.ResponseWriter, req *http.Request) {}
@ -11,4 +12,5 @@ func OK(w http.ResponseWriter, req *http.Request) {}
type V struct {
Hostname string `json:"hostname"`
V string `json:"version"`
G string `json:"git"`
}