chore: disallow sdk imports from the db package, switch enum to string(#14539)

* chore: disallow sdk imports from the db package
* convert to string
This commit is contained in:
Steven Masley
2024-09-03 10:32:33 -05:00
committed by GitHub
parent 48430625a0
commit 7c8c02733d
2 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,6 @@ import (
"golang.org/x/xerrors"
"github.com/coder/coder/v2/coderd/rbac/policy"
"github.com/coder/coder/v2/codersdk/healthsdk"
)
// AuditOAuthConvertState is never stored in the database. It is stored in a cookie
@ -26,8 +25,8 @@ type AuditOAuthConvertState struct {
}
type HealthSettings struct {
ID uuid.UUID `db:"id" json:"id"`
DismissedHealthchecks []healthsdk.HealthSection `db:"dismissed_healthchecks" json:"dismissed_healthchecks"`
ID uuid.UUID `db:"id" json:"id"`
DismissedHealthchecks []string `db:"dismissed_healthchecks" json:"dismissed_healthchecks"`
}
type NotificationsSettings struct {

View File

@ -20,6 +20,7 @@ import (
"github.com/coder/coder/v2/coderd/httpmw"
"github.com/coder/coder/v2/coderd/rbac"
"github.com/coder/coder/v2/coderd/rbac/policy"
"github.com/coder/coder/v2/coderd/util/slice"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/codersdk/healthsdk"
)
@ -250,7 +251,7 @@ func (api *API) putDeploymentHealthSettings(rw http.ResponseWriter, r *http.Requ
aReq.New = database.HealthSettings{
ID: uuid.New(),
DismissedHealthchecks: settings.DismissedHealthchecks,
DismissedHealthchecks: slice.ToStrings(settings.DismissedHealthchecks),
}
err = api.Database.UpsertHealthSettings(ctx, string(settingsJSON))