Commit f539b9bd authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

add git commit to version and expose version in debugapi (#684)

parent ff8e5fab
......@@ -4,10 +4,8 @@ GOLANGCI_LINT_VERSION ?= v1.30.0
GOGOPROTOBUF ?= protoc-gen-gogofaster
GOGOPROTOBUF_VERSION ?= v1.3.1
LDFLAGS ?= -s -w
ifdef COMMIT
LDFLAGS += -X github.com/ethersphere/bee.commit="$(COMMIT)"
endif
COMMIT ?= "$(shell git describe --long --dirty --always --match "" || true)"
LDFLAGS ?= -s -w -X github.com/ethersphere/bee.commit="$(COMMIT)"
.PHONY: all
all: build lint vet test-race binary
......
......@@ -7,15 +7,18 @@ package debugapi
import (
"net/http"
"github.com/ethersphere/bee"
"github.com/ethersphere/bee/pkg/jsonhttp"
)
type statusResponse struct {
Status string `json:"status"`
Status string `json:"status"`
Version string `json:"version"`
}
func (s *server) statusHandler(w http.ResponseWriter, r *http.Request) {
jsonhttp.OK(w, statusResponse{
Status: "ok",
Status: "ok",
Version: bee.Version,
})
}
......@@ -8,6 +8,7 @@ import (
"net/http"
"testing"
"github.com/ethersphere/bee"
"github.com/ethersphere/bee/pkg/debugapi"
"github.com/ethersphere/bee/pkg/jsonhttp/jsonhttptest"
)
......@@ -17,7 +18,8 @@ func TestHealth(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/health", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.StatusResponse{
Status: "ok",
Status: "ok",
Version: bee.Version,
}),
)
}
......@@ -27,7 +29,8 @@ func TestReadiness(t *testing.T) {
jsonhttptest.Request(t, testServer.Client, http.MethodGet, "/readiness", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(debugapi.StatusResponse{
Status: "ok",
Status: "ok",
Version: bee.Version,
}),
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment