diff --git a/server/api/status.go b/server/api/status.go index 6da09278add..123daef2ddf 100644 --- a/server/api/status.go +++ b/server/api/status.go @@ -27,6 +27,7 @@ type statusHandler struct { type status struct { BuildTS string `json:"build_ts"` GitHash string `json:"git_hash"` + Version string `json:"version"` } func newStatusHandler(rd *render.Render) *statusHandler { @@ -39,6 +40,7 @@ func (h *statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { version := status{ BuildTS: server.PDBuildTS, GitHash: server.PDGitHash, + Version: server.PDReleaseVersion, } h.rd.JSON(w, http.StatusOK, version) diff --git a/server/api/status_test.go b/server/api/status_test.go index 702ad1d80af..8e3691b7aff 100644 --- a/server/api/status_test.go +++ b/server/api/status_test.go @@ -38,6 +38,7 @@ func checkStatusResponse(c *C, body []byte, cfgs []*server.Config) { c.Assert(got.BuildTS, Equals, server.PDBuildTS) c.Assert(got.GitHash, Equals, server.PDGitHash) + c.Assert(got.Version, Equals, server.PDReleaseVersion) } func (s *testStatusAPISuite) TestStatus(c *C) { diff --git a/server/api/version.go b/server/api/version.go index 15d43515a56..9aa902248e1 100644 --- a/server/api/version.go +++ b/server/api/version.go @@ -3,6 +3,7 @@ package api import ( "net/http" + "github.com/pingcap/pd/v3/server" "github.com/unrolled/render" ) @@ -22,7 +23,7 @@ func newVersionHandler(rd *render.Render) *versionHandler { func (h *versionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { version := &version{ - Version: "1.0.0", + Version: server.PDReleaseVersion, } h.rd.JSON(w, http.StatusOK, version) }