mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
feat: add dismissed
property to the healthcheck section (#10940)
This commit is contained in:
@ -3,15 +3,17 @@ package coderd
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"cdr.dev/slog"
|
||||
|
||||
"github.com/coder/coder/v2/coderd/audit"
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
@ -253,3 +255,19 @@ func validateHealthSettings(settings codersdk.HealthSettings) error {
|
||||
// @Router /debug/ws [get]
|
||||
// @x-apidocgen {"skip": true}
|
||||
func _debugws(http.ResponseWriter, *http.Request) {} //nolint:unused
|
||||
|
||||
func loadDismissedHealthchecks(ctx context.Context, db database.Store, logger slog.Logger) []string {
|
||||
dismissedHealthchecks := []string{}
|
||||
settingsJSON, err := db.GetHealthSettings(ctx)
|
||||
if err == nil {
|
||||
var settings codersdk.HealthSettings
|
||||
err = json.Unmarshal([]byte(settingsJSON), &settings)
|
||||
if len(settings.DismissedHealthchecks) > 0 {
|
||||
dismissedHealthchecks = settings.DismissedHealthchecks
|
||||
}
|
||||
}
|
||||
if err != nil && !xerrors.Is(err, sql.ErrNoRows) {
|
||||
logger.Error(ctx, "unable to fetch health settings: %w", err)
|
||||
}
|
||||
return dismissedHealthchecks
|
||||
}
|
||||
|
Reference in New Issue
Block a user