mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-29 22:28:01 +00:00
- Fix all errcheck issues (unhandled errors for Close(), Fprintln, etc.) - Fix gosec issues with appropriate nolint comments for test code - Fix misspell issues and add nolint for GitLab API field names - Fix revive issues (dot-imports in tests, missing package comments) - Fix staticcheck and testifylint issues - Add package comments where required by linter This enables updating golangci-lint-action from v6 to v8 in the workflow.
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package controllers
|
|
|
|
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 `validate:"required"`
|
|
Drainer *events.Drainer `validate:"required"`
|
|
AtlantisVersion string `validate:"required"`
|
|
}
|
|
|
|
type StatusResponse struct {
|
|
ShuttingDown bool `json:"shutting_down"`
|
|
InProgressOps int `json:"in_progress_operations"`
|
|
AtlantisVersion string `json:"version"`
|
|
}
|
|
|
|
// Get is the GET /status route.
|
|
func (d *StatusController) Get(w http.ResponseWriter, _ *http.Request) {
|
|
status := d.Drainer.GetStatus()
|
|
data, err := json.MarshalIndent(&StatusResponse{
|
|
ShuttingDown: status.ShuttingDown,
|
|
InProgressOps: status.InProgressOps,
|
|
AtlantisVersion: d.AtlantisVersion,
|
|
}, "", " ")
|
|
if err != nil {
|
|
w.WriteHeader(http.StatusInternalServerError)
|
|
if _, writeErr := fmt.Fprintf(w, "Error creating status json response: %s", err); writeErr != nil {
|
|
d.Logger.Err("failed to write error response: %v", writeErr)
|
|
}
|
|
return
|
|
}
|
|
w.Header().Set("Content-Type", "application/json")
|
|
w.Write(data) // nolint: errcheck
|
|
}
|