MCPcopy Index your code
hub / github.com/coder/coder / deploymentHealthSettings

Method deploymentHealthSettings

coderd/debug.go:172–197  ·  view source on GitHub ↗

@Summary Get health settings @ID get-health-settings @Security CoderSessionToken @Produce json @Tags Debug @Success 200 {object} healthsdk.HealthSettings @Router /api/v2/debug/health/settings [get]

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

170// @Success 200 {object} healthsdk.HealthSettings
171// @Router /api/v2/debug/health/settings [get]
172func (api *API) deploymentHealthSettings(rw http.ResponseWriter, r *http.Request) {
173 settingsJSON, err := api.Database.GetHealthSettings(r.Context())
174 if err != nil {
175 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
176 Message: "Failed to fetch health settings.",
177 Detail: err.Error(),
178 })
179 return
180 }
181
182 var settings healthsdk.HealthSettings
183 err = json.Unmarshal([]byte(settingsJSON), &settings)
184 if err != nil {
185 httpapi.Write(r.Context(), rw, http.StatusInternalServerError, codersdk.Response{
186 Message: "Failed to unmarshal health settings.",
187 Detail: err.Error(),
188 })
189 return
190 }
191
192 if len(settings.DismissedHealthchecks) == 0 {
193 settings.DismissedHealthchecks = []healthsdk.HealthSection{}
194 }
195
196 httpapi.Write(r.Context(), rw, http.StatusOK, settings)
197}
198
199// @Summary Update health settings
200// @ID update-health-settings

Callers

nothing calls this directly

Calls 5

WriteFunction · 0.92
GetHealthSettingsMethod · 0.65
ContextMethod · 0.65
ErrorMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected