Skip to content

Commit d756e93

Browse files
committed
Merge branch 'main' into release2.2.0
2 parents c3d99fa + 0878381 commit d756e93

File tree

21 files changed

+219
-23
lines changed

21 files changed

+219
-23
lines changed

cli/cliui/agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,14 @@ func Agent(ctx context.Context, writer io.Writer, agentID uuid.UUID, opts AgentO
237237
sw.Start(stage)
238238
sw.Log(time.Now(), codersdk.LogLevelWarn, "Wait for it to reconnect or restart your workspace.")
239239
sw.Log(time.Now(), codersdk.LogLevelWarn, troubleshootingMessage(agent, "https://coder.com/docs/v2/latest/templates#agent-connection-issues"))
240+
241+
disconnectedAt := *agent.DisconnectedAt
240242
for agent.Status == codersdk.WorkspaceAgentDisconnected {
241243
if agent, err = fetch(); err != nil {
242244
return xerrors.Errorf("fetch: %w", err)
243245
}
244246
}
245-
sw.Complete(stage, agent.LastConnectedAt.Sub(*agent.DisconnectedAt))
247+
sw.Complete(stage, agent.LastConnectedAt.Sub(disconnectedAt))
246248
}
247249
}
248250
}

cli/cliui/agent_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func TestAgent(t *testing.T) {
133133
},
134134
func(_ context.Context, agent *codersdk.WorkspaceAgent, _ chan []codersdk.WorkspaceAgentLog) error {
135135
agent.Status = codersdk.WorkspaceAgentConnected
136+
agent.DisconnectedAt = nil
136137
agent.LastConnectedAt = ptr.Ref(time.Now())
137138
return nil
138139
},

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

coderd/workspaceagents.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,9 @@ func (api *API) workspaceAgentManifest(rw http.ResponseWriter, r *http.Request)
216216
Username: owner.Username,
217217
}
218218
vscodeProxyURI := api.AccessURL.Scheme + "://" + strings.ReplaceAll(api.AppHostname, "*", appHost.String())
219-
219+
if api.AppHostname == "" {
220+
vscodeProxyURI += api.AccessURL.Hostname()
221+
}
220222
if api.AccessURL.Port() != "" {
221223
vscodeProxyURI += fmt.Sprintf(":%s", api.AccessURL.Port())
222224
}

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)