Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Version to /healthz endpoint #1120

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,8 +590,10 @@ func (s *Server) Index(w http.ResponseWriter, _ *http.Request) {
func (s *Server) Healthz(w http.ResponseWriter, _ *http.Request) {
data, err := json.MarshalIndent(&struct {
Status string `json:"status"`
AtlantisVersion string `json:"atlantisVersion"`
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
}{
Status: "ok",
AtlantisVersion: s.AtlantisVersion,
}, "", " ")
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
Expand Down
7 changes: 5 additions & 2 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ func TestIndex_Success(t *testing.T) {
}

func TestHealthz(t *testing.T) {
s := server.Server{}
s := server.Server{
AtlantisVersion: "0.14.0",
}
req, _ := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
w := httptest.NewRecorder()
s.Healthz(w, req)
Expand All @@ -166,7 +168,8 @@ func TestHealthz(t *testing.T) {
Equals(t, "application/json", w.Result().Header["Content-Type"][0])
Equals(t,
`{
"status": "ok"
"status": "ok",
"atlantisVersion": "0.14.0",
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
}`, string(body))
}

Expand Down