feat: add dismissed property to the healthcheck section (#10940)

This commit is contained in:
Marcin Tojek
2023-11-29 17:37:40 +01:00
committed by GitHub
parent d374becdeb
commit 2b574e2b2d
19 changed files with 225 additions and 38 deletions

View File

@ -15,30 +15,35 @@ import (
"github.com/coder/coder/v2/coderd/healthcheck/health"
)
type WebsocketReportOptions struct {
APIKey string
AccessURL *url.URL
HTTPClient *http.Client
}
// @typescript-generate WebsocketReport
type WebsocketReport struct {
// Healthy is deprecated and left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Dismissed bool `json:"dismissed"`
Body string `json:"body"`
Code int `json:"code"`
Error *string `json:"error"`
}
type WebsocketReportOptions struct {
APIKey string
AccessURL *url.URL
HTTPClient *http.Client
Dismissed bool
}
func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
r.Severity = health.SeverityOK
r.Warnings = []string{}
r.Dismissed = opts.Dismissed
u, err := opts.AccessURL.Parse("/api/v2/debug/ws")
if err != nil {
r.Error = convertError(xerrors.Errorf("parse access url: %w", err))