mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 18:28:22 +00:00
This is two changes: Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
38 lines
944 B
Go
38 lines
944 B
Go
package server
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/runatlantis/atlantis/server/events"
|
|
"github.com/runatlantis/atlantis/server/logging"
|
|
)
|
|
|
|
// StatusController handles the status of Atlantis.
|
|
type StatusController struct {
|
|
Logger logging.SimpleLogging
|
|
Drainer *events.Drainer
|
|
}
|
|
|
|
type StatusResponse struct {
|
|
ShuttingDown bool `json:"shutting_down"`
|
|
InProgressOps int `json:"in_progress_operations"`
|
|
}
|
|
|
|
// Get is the GET /status route.
|
|
func (d *StatusController) Get(w http.ResponseWriter, r *http.Request) {
|
|
status := d.Drainer.GetStatus()
|
|
data, err := json.MarshalIndent(&StatusResponse{
|
|
ShuttingDown: status.ShuttingDown,
|
|
InProgressOps: status.InProgressOps,
|
|
}, "", " ")
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
fmt.Fprintf(w, "Error creating status json response: %s", err)
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Write(data) // nolint: errcheck
|
|
}
|