Skip to content

Commit cb5f8df

Browse files
authored
feat: expose application name via Appearance API (#9886)
1 parent 6873877 commit cb5f8df

File tree

18 files changed

+212
-21
lines changed

18 files changed

+212
-21
lines changed

coderd/apidoc/docs.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbauthz/dbauthz.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,11 @@ func (q *querier) GetAppSecurityKey(ctx context.Context) (string, error) {
851851
return q.db.GetAppSecurityKey(ctx)
852852
}
853853

854+
func (q *querier) GetApplicationName(ctx context.Context) (string, error) {
855+
// No authz checks
856+
return q.db.GetApplicationName(ctx)
857+
}
858+
854859
func (q *querier) GetAuditLogsOffset(ctx context.Context, arg database.GetAuditLogsOffsetParams) ([]database.GetAuditLogsOffsetRow, error) {
855860
// To optimize audit logs, we only check the global audit log permission once.
856861
// This is because we expect a large unbounded set of audit logs, and applying a SQL
@@ -2808,6 +2813,13 @@ func (q *querier) UpsertAppSecurityKey(ctx context.Context, data string) error {
28082813
return q.db.UpsertAppSecurityKey(ctx, data)
28092814
}
28102815

2816+
func (q *querier) UpsertApplicationName(ctx context.Context, value string) error {
2817+
if err := q.authorizeContext(ctx, rbac.ActionCreate, rbac.ResourceDeploymentValues); err != nil {
2818+
return err
2819+
}
2820+
return q.db.UpsertApplicationName(ctx, value)
2821+
}
2822+
28112823
func (q *querier) UpsertDefaultProxy(ctx context.Context, arg database.UpsertDefaultProxyParams) error {
28122824
if err := q.authorizeContext(ctx, rbac.ActionUpdate, rbac.ResourceSystem); err != nil {
28132825
return err

coderd/database/dbfake/dbfake.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ type data struct {
160160
derpMeshKey string
161161
lastUpdateCheck []byte
162162
serviceBanner []byte
163+
applicationName string
163164
logoURL string
164165
appSecurityKey string
165166
oauthSigningKey string
@@ -1128,6 +1129,17 @@ func (q *FakeQuerier) GetAppSecurityKey(_ context.Context) (string, error) {
11281129
return q.appSecurityKey, nil
11291130
}
11301131

1132+
func (q *FakeQuerier) GetApplicationName(_ context.Context) (string, error) {
1133+
q.mutex.RLock()
1134+
defer q.mutex.RUnlock()
1135+
1136+
if q.applicationName == "" {
1137+
return "", sql.ErrNoRows
1138+
}
1139+
1140+
return q.applicationName, nil
1141+
}
1142+
11311143
func (q *FakeQuerier) GetAuditLogsOffset(_ context.Context, arg database.GetAuditLogsOffsetParams) ([]database.GetAuditLogsOffsetRow, error) {
11321144
if err := validateDatabaseType(arg); err != nil {
11331145
return nil, err
@@ -6319,6 +6331,14 @@ func (q *FakeQuerier) UpsertAppSecurityKey(_ context.Context, data string) error
63196331
return nil
63206332
}
63216333

6334+
func (q *FakeQuerier) UpsertApplicationName(_ context.Context, data string) error {
6335+
q.mutex.RLock()
6336+
defer q.mutex.RUnlock()
6337+
6338+
q.applicationName = data
6339+
return nil
6340+
}
6341+
63226342
func (q *FakeQuerier) UpsertDefaultProxy(_ context.Context, arg database.UpsertDefaultProxyParams) error {
63236343
q.defaultProxyDisplayName = arg.DisplayName
63246344
q.defaultProxyIconURL = arg.IconUrl

coderd/database/dbmetrics/dbmetrics.go

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbmock/dbmock.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/querier.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/siteconfig.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'logo_url';
5050
-- name: GetLogoURL :one
5151
SELECT value FROM site_configs WHERE key = 'logo_url';
5252

53+
-- name: UpsertApplicationName :exec
54+
INSERT INTO site_configs (key, value) VALUES ('application_name', $1)
55+
ON CONFLICT (key) DO UPDATE SET value = $1 WHERE site_configs.key = 'application_name';
56+
57+
-- name: GetApplicationName :one
58+
SELECT value FROM site_configs WHERE key = 'application_name';
59+
5360
-- name: GetAppSecurityKey :one
5461
SELECT value FROM site_configs WHERE key = 'app_signing_key';
5562

codersdk/deployment.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,14 +1832,16 @@ func (c *Client) DeploymentStats(ctx context.Context) (DeploymentStats, error) {
18321832
}
18331833

18341834
type AppearanceConfig struct {
1835-
LogoURL string `json:"logo_url"`
1836-
ServiceBanner ServiceBannerConfig `json:"service_banner"`
1837-
SupportLinks []LinkConfig `json:"support_links,omitempty"`
1835+
ApplicationName string `json:"application_name"`
1836+
LogoURL string `json:"logo_url"`
1837+
ServiceBanner ServiceBannerConfig `json:"service_banner"`
1838+
SupportLinks []LinkConfig `json:"support_links,omitempty"`
18381839
}
18391840

18401841
type UpdateAppearanceConfig struct {
1841-
LogoURL string `json:"logo_url"`
1842-
ServiceBanner ServiceBannerConfig `json:"service_banner"`
1842+
ApplicationName string `json:"application_name"`
1843+
LogoURL string `json:"logo_url"`
1844+
ServiceBanner ServiceBannerConfig `json:"service_banner"`
18431845
}
18441846

18451847
type ServiceBannerConfig struct {

docs/api/enterprise.md

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/schemas.md

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)