From 56bd8445a4ac7ad68283be78ac516b6c804e4fc8 Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Thu, 8 Mar 2018 16:15:44 -0800 Subject: [PATCH] Consolidates the V struct --- cmd/hw/main.go | 7 +------ cmd/hwc/main.go | 7 +------ hw.go | 6 ++++++ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/cmd/hw/main.go b/cmd/hw/main.go index e6de592..2212c99 100644 --- a/cmd/hw/main.go +++ b/cmd/hw/main.go @@ -13,11 +13,6 @@ import ( "mcquay.me/metrics" ) -type v struct { - Hostname string `json:"hostname"` - V string `json:"version"` -} - func main() { m, err := metrics.New("hw") if err != nil { @@ -29,7 +24,7 @@ func main() { } http.HandleFunc("/", m.WrapFunc("/", func(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "application/json") - r := v{ + r := hw.V{ Hostname: hn, V: hw.Version, } diff --git a/cmd/hwc/main.go b/cmd/hwc/main.go index 38a141e..33d33be 100644 --- a/cmd/hwc/main.go +++ b/cmd/hwc/main.go @@ -17,11 +17,6 @@ import ( var success *prometheus.CounterVec -type v struct { - Hostname string `json:"hostname"` - V string `json:"version"` -} - type state struct { Hostname string `json:"hostname"` V string `json:"version"` @@ -45,7 +40,7 @@ func (s *state) update(target string) { continue } success.WithLabelValues("true").Inc() - rv := v{} + rv := hw.V{} if err := json.NewDecoder(httpResp.Body).Decode(&rv); err != nil { panic(err) } diff --git a/hw.go b/hw.go index b3b9d55..aedec73 100644 --- a/hw.go +++ b/hw.go @@ -6,3 +6,9 @@ var Version = "unset" // OK simply return 200 func OK(w http.ResponseWriter, req *http.Request) {} + +// V houses version information +type V struct { + Hostname string `json:"hostname"` + V string `json:"version"` +}