Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 19b6d19

Browse files
authored
feat: manage health settings using Coder API (#10861)
1 parent 452668c commit 19b6d19

20 files changed

+603
-4
lines changed

coderd/apidoc/docs.go

+86
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/audit/diff.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ type Auditable interface {
1818
database.AuditableGroup |
1919
database.License |
2020
database.WorkspaceProxy |
21-
database.AuditOAuthConvertState
21+
database.AuditOAuthConvertState |
22+
database.HealthSettings
2223
}
2324

2425
// Map is a map of changed fields in an audited resource. It maps field names to

coderd/audit/request.go

+7
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ func ResourceTarget[T Auditable](tgt T) string {
9393
return typed.Name
9494
case database.AuditOAuthConvertState:
9595
return string(typed.ToLoginType)
96+
case database.HealthSettings:
97+
return "" // no target?
9698
default:
9799
panic(fmt.Sprintf("unknown resource %T", tgt))
98100
}
@@ -123,6 +125,9 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
123125
case database.AuditOAuthConvertState:
124126
// The merge state is for the given user
125127
return typed.UserID
128+
case database.HealthSettings:
129+
// Artificial ID for auditing purposes
130+
return typed.ID
126131
default:
127132
panic(fmt.Sprintf("unknown resource %T", tgt))
128133
}
@@ -152,6 +157,8 @@ func ResourceType[T Auditable](tgt T) database.ResourceType {
152157
return database.ResourceTypeWorkspaceProxy
153158
case database.AuditOAuthConvertState:
154159
return database.ResourceTypeConvertLogin
160+
case database.HealthSettings:
161+
return database.ResourceTypeHealthSettings
155162
default:
156163
panic(fmt.Sprintf("unknown resource %T", typed))
157164
}

coderd/coderd.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,13 @@ func New(options *Options) *API {
970970

971971
r.Get("/coordinator", api.debugCoordinator)
972972
r.Get("/tailnet", api.debugTailnet)
973-
r.Get("/health", api.debugDeploymentHealth)
973+
r.Route("/health", func(r chi.Router) {
974+
r.Get("/", api.debugDeploymentHealth)
975+
r.Route("/settings", func(r chi.Router) {
976+
r.Get("/", api.deploymentHealthSettings)
977+
r.Put("/", api.putDeploymentHealthSettings)
978+
})
979+
})
974980
r.Get("/ws", (&healthcheck.WebsocketEchoServer{}).ServeHTTP)
975981
r.Route("/{user}", func(r chi.Router) {
976982
r.Use(httpmw.ExtractUserParam(options.Database))

coderd/database/dump.sql

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-- Nothing to do
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- This has to be outside a transaction
2+
ALTER TYPE resource_type ADD VALUE IF NOT EXISTS 'health_settings';

coderd/database/models.go

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/types.go

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ type AuditOAuthConvertState struct {
2323
UserID uuid.UUID `db:"user_id" json:"user_id"`
2424
}
2525

26+
type HealthSettings struct {
27+
ID uuid.UUID `db:"id" json:"id"`
28+
DismissedHealthchecks []string `db:"dismissed_healthchecks" json:"dismissed_healthchecks"`
29+
}
30+
2631
type Actions []rbac.Action
2732

2833
func (a *Actions) Scan(src interface{}) error {

0 commit comments

Comments
 (0)