From 289db739173a24fcee8103e3f16dee6ad8ab5c87 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 14:04:07 +0000 Subject: [PATCH 01/24] feat: Add flag to allow workspace renames --- coderd/workspaces.go | 28 ++++++++++++++++++++++------ codersdk/deployment.go | 11 +++++++++++ codersdk/workspaces.go | 1 + 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/coderd/workspaces.go b/coderd/workspaces.go index 238780b1ec1b6..51b6666e29c78 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -106,6 +106,7 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, + api.DeploymentValues.AllowWorkspaceRenames.Value(), )) } @@ -277,6 +278,7 @@ func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request) data.builds[0], data.templates[0], ownerName, + api.DeploymentValues.AllowWorkspaceRenames.Value(), )) } @@ -585,6 +587,7 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req apiBuild, template, member.Username, + api.DeploymentValues.AllowWorkspaceRenames.Value(), )) } @@ -628,6 +631,12 @@ func (api *API) patchWorkspace(rw http.ResponseWriter, r *http.Request) { // patched in the future, it's enough if one changes. name := workspace.Name if req.Name != "" || req.Name != workspace.Name { + if !api.DeploymentValues.AllowWorkspaceRenames.Value() { + httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ + Message: "Workspace renames are not allowed.", + }) + return + } name = req.Name } @@ -917,6 +926,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, + api.DeploymentValues.AllowWorkspaceRenames.Value(), )) } @@ -1242,6 +1252,7 @@ func (api *API) watchWorkspace(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, + api.DeploymentValues.AllowWorkspaceRenames.Value(), ), }) } @@ -1293,9 +1304,10 @@ func (api *API) watchWorkspace(rw http.ResponseWriter, r *http.Request) { } type workspaceData struct { - templates []database.Template - builds []codersdk.WorkspaceBuild - users []database.User + templates []database.Template + builds []codersdk.WorkspaceBuild + users []database.User + allowRenames bool } // workspacesData only returns the data the caller can access. If the caller @@ -1347,9 +1359,10 @@ func (api *API) workspaceData(ctx context.Context, workspaces []database.Workspa } return workspaceData{ - templates: templates, - builds: apiBuilds, - users: data.users, + templates: templates, + builds: apiBuilds, + users: data.users, + allowRenames: api.DeploymentValues.AllowWorkspaceRenames.Value(), }, nil } @@ -1392,6 +1405,7 @@ func convertWorkspaces(workspaces []database.Workspace, data workspaceData) ([]c build, template, owner.Username, + data.allowRenames, )) } return apiWorkspaces, nil @@ -1402,6 +1416,7 @@ func convertWorkspace( workspaceBuild codersdk.WorkspaceBuild, template database.Template, ownerName string, + allowRenames bool, ) codersdk.Workspace { var autostartSchedule *string if workspace.AutostartSchedule.Valid { @@ -1456,6 +1471,7 @@ func convertWorkspace( FailingAgents: failingAgents, }, AutomaticUpdates: codersdk.AutomaticUpdates(workspace.AutomaticUpdates), + AllowRenames: allowRenames, } } diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 1e8a4c93ccf98..0e77cc2943bd2 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -181,6 +181,7 @@ type DeploymentValues struct { EnableTerraformDebugMode clibase.Bool `json:"enable_terraform_debug_mode,omitempty" typescript:",notnull"` UserQuietHoursSchedule UserQuietHoursScheduleConfig `json:"user_quiet_hours_schedule,omitempty" typescript:",notnull"` WebTerminalRenderer clibase.String `json:"web_terminal_renderer,omitempty" typescript:",notnull"` + AllowWorkspaceRenames clibase.Bool `json:"allow_workspace_renames,omitempty" typescript:",notnull"` Healthcheck HealthcheckConfig `json:"healthcheck,omitempty" typescript:",notnull"` Config clibase.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"` @@ -1842,6 +1843,16 @@ Write out the current server config as YAML to stdout.`, Group: &deploymentGroupClient, YAML: "webTerminalRenderer", }, + { + Name: "Allow Workspace Renames", + Description: "Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons.", + Flag: "allow-workspace-renames", + Env: "CODER_ALLOW_WORKSPACE_RENAMES", + Default: "false", + Value: &c.AllowWorkspaceRenames, + Group: &deploymentGroupConfig, + YAML: "allowWorkspaceRenames", + }, // Healthcheck Options { Name: "Health Check Refresh", diff --git a/codersdk/workspaces.go b/codersdk/workspaces.go index 307bbdb0d3b93..59dede325ee0b 100644 --- a/codersdk/workspaces.go +++ b/codersdk/workspaces.go @@ -57,6 +57,7 @@ type Workspace struct { // what is causing an unhealthy status. Health WorkspaceHealth `json:"health"` AutomaticUpdates AutomaticUpdates `json:"automatic_updates" enums:"always,never"` + AllowRenames bool `json:"allow_renames"` } func (w Workspace) FullName() string { From b1673fef1a6c08d2e2f5d75bf8ca874e1d074100 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 14:07:35 +0000 Subject: [PATCH 02/24] make gen --- coderd/apidoc/docs.go | 6 ++++++ coderd/apidoc/swagger.json | 6 ++++++ docs/api/general.md | 1 + docs/api/schemas.md | 6 ++++++ docs/api/workspaces.md | 5 +++++ docs/cli/server.md | 13 +++++++++++++ site/src/api/typesGenerated.ts | 2 ++ 7 files changed, 39 insertions(+) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 569ade9033a13..0bf86fc999dd3 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -8558,6 +8558,9 @@ const docTemplate = `{ "agent_stat_refresh_interval": { "type": "integer" }, + "allow_workspace_renames": { + "type": "boolean" + }, "autobuild_poll_interval": { "type": "integer" }, @@ -11443,6 +11446,9 @@ const docTemplate = `{ "codersdk.Workspace": { "type": "object", "properties": { + "allow_renames": { + "type": "boolean" + }, "automatic_updates": { "enum": [ "always", diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 30d83cc50c780..2187fd7a05cf8 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -7642,6 +7642,9 @@ "agent_stat_refresh_interval": { "type": "integer" }, + "allow_workspace_renames": { + "type": "boolean" + }, "autobuild_poll_interval": { "type": "integer" }, @@ -10372,6 +10375,9 @@ "codersdk.Workspace": { "type": "object", "properties": { + "allow_renames": { + "type": "boolean" + }, "automatic_updates": { "enum": ["always", "never"], "allOf": [ diff --git a/docs/api/general.md b/docs/api/general.md index 043913bbf2eb8..65d9d4badd499 100644 --- a/docs/api/general.md +++ b/docs/api/general.md @@ -153,6 +153,7 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \ "user": {} }, "agent_stat_refresh_interval": 0, + "allow_workspace_renames": true, "autobuild_poll_interval": 0, "browser_only": true, "cache_directory": "string", diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 21eb6dba26ada..991f57bccbb0c 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -2083,6 +2083,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "user": {} }, "agent_stat_refresh_interval": 0, + "allow_workspace_renames": true, "autobuild_poll_interval": 0, "browser_only": true, "cache_directory": "string", @@ -2460,6 +2461,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "user": {} }, "agent_stat_refresh_interval": 0, + "allow_workspace_renames": true, "autobuild_poll_interval": 0, "browser_only": true, "cache_directory": "string", @@ -2732,6 +2734,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `address` | [clibase.HostPort](#clibasehostport) | false | | Address Use HTTPAddress or TLS.Address instead. | | `agent_fallback_troubleshooting_url` | [clibase.URL](#clibaseurl) | false | | | | `agent_stat_refresh_interval` | integer | false | | | +| `allow_workspace_renames` | boolean | false | | | | `autobuild_poll_interval` | integer | false | | | | `browser_only` | boolean | false | | | | `cache_directory` | string | false | | | @@ -5764,6 +5767,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| ```json { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", @@ -5943,6 +5947,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| | Name | Type | Required | Restrictions | Description | | ------------------------------------------- | ------------------------------------------------------ | -------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `allow_renames` | boolean | false | | | | `automatic_updates` | [codersdk.AutomaticUpdates](#codersdkautomaticupdates) | false | | | | `autostart_schedule` | string | false | | | | `created_at` | string | false | | | @@ -7025,6 +7030,7 @@ If the schedule is empty, the user will be updated to use the default schedule.| "count": 0, "workspaces": [ { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", diff --git a/docs/api/workspaces.md b/docs/api/workspaces.md index 7d0f7973d4425..f825ba5f7c679 100644 --- a/docs/api/workspaces.md +++ b/docs/api/workspaces.md @@ -47,6 +47,7 @@ curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/member ```json { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", @@ -257,6 +258,7 @@ curl -X GET http://coder-server:8080/api/v2/users/{user}/workspace/{workspacenam ```json { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", @@ -470,6 +472,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaces \ "count": 0, "workspaces": [ { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", @@ -677,6 +680,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace} \ ```json { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", @@ -1003,6 +1007,7 @@ curl -X PUT http://coder-server:8080/api/v2/workspaces/{workspace}/dormant \ ```json { + "allow_renames": true, "automatic_updates": "always", "autostart_schedule": "string", "created_at": "2019-08-24T14:15:22Z", diff --git a/docs/cli/server.md b/docs/cli/server.md index 34fe77b3a59a3..8056d9524cede 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -31,6 +31,7 @@ coder server [flags] The URL that users will use to access the Coder deployment. +<<<<<<< HEAD ### --allow-custom-quiet-hours | | | @@ -41,6 +42,18 @@ The URL that users will use to access the Coder deployment. | Default | true | Allow users to set their own quiet hours schedule for workspaces to stop in (depending on template autostop requirement settings). If false, users can't change their quiet hours schedule and the site default is always used. +======= +### --allow-workspace-renames + +| | | +| ----------- | ------------------------------------------- | +| Type | bool | +| Environment | $CODER_ALLOW_WORKSPACE_RENAMES | +| YAML | .allowWorkspaceRenames | +| Default | false | + +Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons. +>>>>>>> 2a4d16f2d (make gen) ### --block-direct-connections diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 934f2681fd4a9..53b3eb90672c3 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -424,6 +424,7 @@ export interface DeploymentValues { readonly enable_terraform_debug_mode?: boolean; readonly user_quiet_hours_schedule?: UserQuietHoursScheduleConfig; readonly web_terminal_renderer?: string; + readonly allow_workspace_renames?: boolean; readonly healthcheck?: HealthcheckConfig; readonly config?: string; readonly write_config?: boolean; @@ -1429,6 +1430,7 @@ export interface Workspace { readonly dormant_at?: string; readonly health: WorkspaceHealth; readonly automatic_updates: AutomaticUpdates; + readonly allow_renames: boolean; } // From codersdk/workspaceagents.go From 49e6be62e062d206002a8b8b081143ded5b9253e Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 14:35:40 +0000 Subject: [PATCH 03/24] add tests --- cli/server.go | 13 +++++++++ coderd/coderdtest/coderdtest.go | 8 +++++ coderd/workspaces.go | 20 ++++++++----- coderd/workspaces_test.go | 52 ++++++++++++++++++++++++++++++++- 4 files changed, 85 insertions(+), 8 deletions(-) diff --git a/cli/server.go b/cli/server.go index 214c4d3a94c97..e7522ecaf69e2 100644 --- a/cli/server.go +++ b/cli/server.go @@ -583,6 +583,10 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. HostnamePrefix: vals.SSHConfig.DeploymentName.String(), SSHConfigOptions: configSSHOptions, }, + AllowWorkspaceRenames: vals.AllowWorkspaceRenames.Value(), + // we are experimenting with self destructing flags that stop working after a certain date. + // This flag should be removed after the date specified below. + AllowWorkspaceRenamesExpiresAt: mustParseTime(time.RFC3339, "2024-04-01T00:00:00Z00:00"), } if httpServers.TLSConfig != nil { options.TLSCertificates = httpServers.TLSConfig.Certificates @@ -2548,3 +2552,12 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder } return providers, nil } + +func mustParseTime(layout string, timeString string) time.Time { + t, err := time.Parse(layout, timeString) + if err != nil { + panic(err) + } + + return t +} diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index 4d1f832ea9c1e..2cef1ab74b71d 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -144,6 +144,8 @@ type Options struct { StatsBatcher *batchstats.Batcher WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions + AllowWorkspaceRenames bool + AllowWorkspaceRenamesExpiresAt time.Time } // New constructs a codersdk client connected to an in-memory API instance. @@ -397,6 +399,10 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can derpMap, err := tailnet.NewDERPMap(ctx, region, stunAddresses, "", "", options.DeploymentValues.DERP.Config.BlockDirect.Value()) require.NoError(t, err) + if options.AllowWorkspaceRenamesExpiresAt.IsZero() { + options.AllowWorkspaceRenamesExpiresAt = time.Now().Add(time.Hour) + } + return func(h http.Handler) { mutex.Lock() defer mutex.Unlock() @@ -449,6 +455,8 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can HealthcheckRefresh: options.HealthcheckRefresh, StatsBatcher: options.StatsBatcher, WorkspaceAppsStatsCollectorOptions: options.WorkspaceAppsStatsCollectorOptions, + AllowWorkspaceRenames: options.AllowWorkspaceRenames, + AllowWorkspaceRenamesExpiresAt: options.AllowWorkspaceRenamesExpiresAt, } } diff --git a/coderd/workspaces.go b/coderd/workspaces.go index 51b6666e29c78..0460761b86ae0 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -106,7 +106,7 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, - api.DeploymentValues.AllowWorkspaceRenames.Value(), + api.Options.AllowWorkspaceRenames, )) } @@ -278,7 +278,7 @@ func (api *API) workspaceByOwnerAndName(rw http.ResponseWriter, r *http.Request) data.builds[0], data.templates[0], ownerName, - api.DeploymentValues.AllowWorkspaceRenames.Value(), + api.Options.AllowWorkspaceRenames, )) } @@ -587,7 +587,7 @@ func (api *API) postWorkspacesByOrganization(rw http.ResponseWriter, r *http.Req apiBuild, template, member.Username, - api.DeploymentValues.AllowWorkspaceRenames.Value(), + api.Options.AllowWorkspaceRenames, )) } @@ -631,12 +631,18 @@ func (api *API) patchWorkspace(rw http.ResponseWriter, r *http.Request) { // patched in the future, it's enough if one changes. name := workspace.Name if req.Name != "" || req.Name != workspace.Name { - if !api.DeploymentValues.AllowWorkspaceRenames.Value() { + if !api.Options.AllowWorkspaceRenames { httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ Message: "Workspace renames are not allowed.", }) return } + if api.Options.AllowWorkspaceRenamesExpiresAt.Before(time.Now()) { + httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ + Message: "Workspace renames are no longer allowed. Flag expired at " + api.Options.AllowWorkspaceRenamesExpiresAt.String(), + }) + return + } name = req.Name } @@ -926,7 +932,7 @@ func (api *API) putWorkspaceDormant(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, - api.DeploymentValues.AllowWorkspaceRenames.Value(), + api.Options.AllowWorkspaceRenames, )) } @@ -1252,7 +1258,7 @@ func (api *API) watchWorkspace(rw http.ResponseWriter, r *http.Request) { data.builds[0], data.templates[0], ownerName, - api.DeploymentValues.AllowWorkspaceRenames.Value(), + api.Options.AllowWorkspaceRenames, ), }) } @@ -1362,7 +1368,7 @@ func (api *API) workspaceData(ctx context.Context, workspaces []database.Workspa templates: templates, builds: apiBuilds, users: data.users, - allowRenames: api.DeploymentValues.AllowWorkspaceRenames.Value(), + allowRenames: api.Options.AllowWorkspaceRenames, }, nil } diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 9c6129b5373f8..dfb9c4a95bbb6 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -100,7 +100,10 @@ func TestWorkspace(t *testing.T) { t.Run("Rename", func(t *testing.T) { t.Parallel() - client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) + client := coderdtest.New(t, &coderdtest.Options{ + IncludeProvisionerDaemon: true, + AllowWorkspaceRenames: true, + }) user := coderdtest.CreateFirstUser(t, client) version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) @@ -134,6 +137,53 @@ func TestWorkspace(t *testing.T) { require.Error(t, err, "workspace rename should have failed") }) + t.Run("RenameDisabled", func(t *testing.T) { + t.Parallel() + client := coderdtest.New(t, &coderdtest.Options{ + IncludeProvisionerDaemon: true, + AllowWorkspaceRenames: false, + }) + user := coderdtest.CreateFirstUser(t, client) + version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) + coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) + template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) + ws1 := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) + coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws1.LatestBuild.ID) + + ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) + defer cancel() + + want := "new-name" + err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{ + Name: want, + }) + require.ErrorContains(t, err, "Workspace renames are not allowed") + }) + + t.Run("RenameExpired", func(t *testing.T) { + t.Parallel() + client := coderdtest.New(t, &coderdtest.Options{ + IncludeProvisionerDaemon: true, + AllowWorkspaceRenames: true, + AllowWorkspaceRenamesExpiresAt: time.Now().Add(-1 * time.Hour), + }) + user := coderdtest.CreateFirstUser(t, client) + version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) + coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) + template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) + ws1 := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) + coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws1.LatestBuild.ID) + + ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) + defer cancel() + + want := "new-name" + err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{ + Name: want, + }) + require.ErrorContains(t, err, "Workspace renames are no longer allowed") + }) + t.Run("TemplateProperties", func(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) From 9faf9e34d8556dbbedd44c2bc4729bc511807dea Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 14:42:57 +0000 Subject: [PATCH 04/24] edit description --- codersdk/deployment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 0e77cc2943bd2..9364d28cdfe9c 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -1845,7 +1845,7 @@ Write out the current server config as YAML to stdout.`, }, { Name: "Allow Workspace Renames", - Description: "Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons.", + Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01T00:00:00Z00:00.", Flag: "allow-workspace-renames", Env: "CODER_ALLOW_WORKSPACE_RENAMES", Default: "false", From ca5cbe053d27708fb3f89162c0d5cb1133a81754 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 14:48:29 +0000 Subject: [PATCH 05/24] make gen --- docs/cli/server.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/cli/server.md b/docs/cli/server.md index 8056d9524cede..d4c6550aa58f1 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -52,8 +52,12 @@ Allow users to set their own quiet hours schedule for workspaces to stop in (dep | YAML | .allowWorkspaceRenames | | Default | false | +<<<<<<< HEAD Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons. >>>>>>> 2a4d16f2d (make gen) +======= +DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01T00:00:00Z00:00. +>>>>>>> a05de9cdc (make gen) ### --block-direct-connections From ebe9180a0315cc80e03b280c71236c448df23ad9 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 17:52:24 +0000 Subject: [PATCH 06/24] correct api response --- cli/server.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cli/server.go b/cli/server.go index e7522ecaf69e2..875174c973ba5 100644 --- a/cli/server.go +++ b/cli/server.go @@ -583,10 +583,10 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. HostnamePrefix: vals.SSHConfig.DeploymentName.String(), SSHConfigOptions: configSSHOptions, }, - AllowWorkspaceRenames: vals.AllowWorkspaceRenames.Value(), // we are experimenting with self destructing flags that stop working after a certain date. // This flag should be removed after the date specified below. - AllowWorkspaceRenamesExpiresAt: mustParseTime(time.RFC3339, "2024-04-01T00:00:00Z00:00"), + AllowWorkspaceRenames: shouldAllowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()), + AllowWorkspaceRenamesExpiresAt: workspaceRenamesExpiresAt(), } if httpServers.TLSConfig != nil { options.TLSCertificates = httpServers.TLSConfig.Certificates @@ -2553,11 +2553,19 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder return providers, nil } -func mustParseTime(layout string, timeString string) time.Time { - t, err := time.Parse(layout, timeString) +const ( + workspaceRenamesExpiresAtTime = "2024-04-01T00:00:00Z" +) + +func workspaceRenamesExpiresAt() time.Time { + t, err := time.Parse(time.RFC3339, workspaceRenamesExpiresAtTime) if err != nil { panic(err) } return t } + +func shouldAllowWorkspaceRenames(value bool) bool { + return value && time.Now().Before(workspaceRenamesExpiresAt()) +} From f572f9dfe9e65f0692ee8ee9640ad3635d33f038 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 17:52:32 +0000 Subject: [PATCH 07/24] frontend form --- .../src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 4 ++-- site/src/testHelpers/entities.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index b94eabee07fb4..ca352adb767eb 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -59,7 +59,7 @@ export const WorkspaceSettingsForm: FC<{ )} - + ); }; diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index 14b475a6d1377..ad61a8804af25 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -1006,6 +1006,7 @@ export const MockWorkspace: TypesGen.Workspace = { failing_agents: [], }, automatic_updates: "never", + allow_renames: false, }; export const MockStoppedWorkspace: TypesGen.Workspace = { From dd629ae5652716c5274ec9648924fa32ffa7c9f4 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 17:59:21 +0000 Subject: [PATCH 08/24] make fmt --- .../pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index ca352adb767eb..acc7bfb3e134f 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -106,7 +106,11 @@ export const WorkspaceSettingsForm: FC<{ )} - + ); }; From 5fd24a7df94e17216507c238676e451e9e7bf805 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 18:00:04 +0000 Subject: [PATCH 09/24] fix test --- site/src/testHelpers/entities.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index ad61a8804af25..743dcd57b7f12 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -1006,7 +1006,7 @@ export const MockWorkspace: TypesGen.Workspace = { failing_agents: [], }, automatic_updates: "never", - allow_renames: false, + allow_renames: true, }; export const MockStoppedWorkspace: TypesGen.Workspace = { From b84bca273480d6f41819d921ad7b27a47515d099 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 19:42:11 +0000 Subject: [PATCH 10/24] update golden --- cli/testdata/coder_list_--output_json.golden | 3 ++- cli/testdata/coder_server_--help.golden | 5 +++++ cli/testdata/server-config.yaml.golden | 14 ++++++++++++++ codersdk/deployment.go | 3 +-- docs/cli/server.md | 9 ++++----- enterprise/cli/testdata/coder_server_--help.golden | 5 +++++ 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/cli/testdata/coder_list_--output_json.golden b/cli/testdata/coder_list_--output_json.golden index fb6bea96e82ba..55b660694810d 100644 --- a/cli/testdata/coder_list_--output_json.golden +++ b/cli/testdata/coder_list_--output_json.golden @@ -59,6 +59,7 @@ "healthy": true, "failing_agents": [] }, - "automatic_updates": "never" + "automatic_updates": "never", + "allow_renames": false } ] diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index 80849f1904cca..5deee037497bf 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -14,6 +14,11 @@ SUBCOMMANDS: PostgreSQL deployment. OPTIONS: + --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) + DEPRECATED: Allow users to rename their workspaces. Use only for + temporary compatibility reasons, this flag will no longer function + after 2024-04-01. + --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index ef071c8b292a6..454d096227f59 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -450,6 +450,7 @@ wgtunnelHost: "" userQuietHoursSchedule: # The default daily cron schedule applied to users that haven't set a custom quiet # hours schedule themselves. The quiet hours schedule determines when workspaces +<<<<<<< HEAD # will be force stopped due to the template's autostop requirement, and will round # the max deadline up to be within the user's quiet hours window (or default). The # format is the same as the standard cron format, but the day-of-month, month and @@ -462,3 +463,16 @@ userQuietHoursSchedule: # change their quiet hours schedule and the site default is always used. # (default: true, type: bool) allowCustomQuietHours: true +======= + # will be force stopped due to the template's max TTL, and will round the max TTL + # up to be within the user's quiet hours window (or default). The format is the + # same as the standard cron format, but the day-of-month, month and day-of-week + # must be *. Only one hour and minute can be specified (ranges or comma separated + # values are not supported). + # (default: , type: string) + defaultQuietHoursSchedule: "" +# DEPRECATED: Allow users to rename their workspaces. Use only for temporary +# compatibility reasons, this flag will no longer function after 2024-04-01. +# (default: false, type: bool) +allowWorkspaceRenames: false +>>>>>>> 899e802d6 (update golden) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 9364d28cdfe9c..433db33b43337 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -1845,12 +1845,11 @@ Write out the current server config as YAML to stdout.`, }, { Name: "Allow Workspace Renames", - Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01T00:00:00Z00:00.", + Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01.", Flag: "allow-workspace-renames", Env: "CODER_ALLOW_WORKSPACE_RENAMES", Default: "false", Value: &c.AllowWorkspaceRenames, - Group: &deploymentGroupConfig, YAML: "allowWorkspaceRenames", }, // Healthcheck Options diff --git a/docs/cli/server.md b/docs/cli/server.md index d4c6550aa58f1..c89ce2b11931b 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -49,15 +49,14 @@ Allow users to set their own quiet hours schedule for workspaces to stop in (dep | ----------- | ------------------------------------------- | | Type | bool | | Environment | $CODER_ALLOW_WORKSPACE_RENAMES | -| YAML | .allowWorkspaceRenames | +| YAML | allowWorkspaceRenames | | Default | false | -<<<<<<< HEAD + Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons. ->>>>>>> 2a4d16f2d (make gen) -======= + DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01T00:00:00Z00:00. ->>>>>>> a05de9cdc (make gen) + ### --block-direct-connections diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index ad404185f0482..7cf8dd21f6d75 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -15,6 +15,11 @@ SUBCOMMANDS: PostgreSQL deployment. OPTIONS: + --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) + DEPRECATED: Allow users to rename their workspaces. Use only for + temporary compatibility reasons, this flag will no longer function + after 2024-04-01. + --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and $CACHE_DIRECTORY is set, it will be used for compatibility with From d81123897f2f5b533fe047428b72d31405bc8390 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 19:47:49 +0000 Subject: [PATCH 11/24] fix cli test --- cli/rename_test.go | 2 +- coderd/workspaces.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/rename_test.go b/cli/rename_test.go index 5a08d29c5a7c4..adbe946c0cb82 100644 --- a/cli/rename_test.go +++ b/cli/rename_test.go @@ -15,7 +15,7 @@ import ( func TestRename(t *testing.T) { t.Parallel() - client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) + client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true, AllowWorkspaceRenames: true}) owner := coderdtest.CreateFirstUser(t, client) member, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID) version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil) diff --git a/coderd/workspaces.go b/coderd/workspaces.go index 0460761b86ae0..2f3cb21363a82 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -632,13 +632,13 @@ func (api *API) patchWorkspace(rw http.ResponseWriter, r *http.Request) { name := workspace.Name if req.Name != "" || req.Name != workspace.Name { if !api.Options.AllowWorkspaceRenames { - httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ + httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ Message: "Workspace renames are not allowed.", }) return } if api.Options.AllowWorkspaceRenamesExpiresAt.Before(time.Now()) { - httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ + httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ Message: "Workspace renames are no longer allowed. Flag expired at " + api.Options.AllowWorkspaceRenamesExpiresAt.String(), }) return From 691b8c5d337476375c4b0d6a38bc9ce0401b09c7 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Wed, 13 Dec 2023 19:59:16 +0000 Subject: [PATCH 12/24] fix watcher test --- coderd/workspaces_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index dfb9c4a95bbb6..d8becc2be8b99 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -2202,7 +2202,10 @@ func TestUpdateWorkspaceAutomaticUpdates_NotFound(t *testing.T) { func TestWorkspaceWatcher(t *testing.T) { t.Parallel() - client, closeFunc := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) + client, closeFunc := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{ + IncludeProvisionerDaemon: true, + AllowWorkspaceRenames: true, + }) defer closeFunc.Close() user := coderdtest.CreateFirstUser(t, client) authToken := uuid.NewString() From 4da4093d9c58c1538fdfb18ed7a213b153a3f574 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Thu, 14 Dec 2023 13:29:54 +0000 Subject: [PATCH 13/24] address pr comments --- cli/server.go | 20 +++----------------- coderd/coderd.go | 3 ++- coderd/coderdtest/coderdtest.go | 6 ------ coderd/workspaces.go | 6 ------ coderd/workspaces_test.go | 24 ------------------------ codersdk/deployment.go | 3 ++- codersdk/workspaces.go | 2 ++ 7 files changed, 9 insertions(+), 55 deletions(-) diff --git a/cli/server.go b/cli/server.go index 875174c973ba5..7861383e12c9f 100644 --- a/cli/server.go +++ b/cli/server.go @@ -585,8 +585,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. }, // we are experimenting with self destructing flags that stop working after a certain date. // This flag should be removed after the date specified below. - AllowWorkspaceRenames: shouldAllowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()), - AllowWorkspaceRenamesExpiresAt: workspaceRenamesExpiresAt(), + AllowWorkspaceRenames: allowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()), } if httpServers.TLSConfig != nil { options.TLSCertificates = httpServers.TLSConfig.Certificates @@ -2553,19 +2552,6 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder return providers, nil } -const ( - workspaceRenamesExpiresAtTime = "2024-04-01T00:00:00Z" -) - -func workspaceRenamesExpiresAt() time.Time { - t, err := time.Parse(time.RFC3339, workspaceRenamesExpiresAtTime) - if err != nil { - panic(err) - } - - return t -} - -func shouldAllowWorkspaceRenames(value bool) bool { - return value && time.Now().Before(workspaceRenamesExpiresAt()) +func allowWorkspaceRenames(flagValue bool) bool { + return flagValue && time.Now().Before(codersdk.WorkspaceRenameDeadline) } diff --git a/coderd/coderd.go b/coderd/coderd.go index 8dd8cf36936fb..0e7421aa2d257 100644 --- a/coderd/coderd.go +++ b/coderd/coderd.go @@ -179,7 +179,8 @@ type Options struct { // This janky function is used in telemetry to parse fields out of the raw // JWT. It needs to be passed through like this because license parsing is // under the enterprise license, and can't be imported into AGPL. - ParseLicenseClaims func(rawJWT string) (email string, trial bool, err error) + ParseLicenseClaims func(rawJWT string) (email string, trial bool, err error) + AllowWorkspaceRenames bool } // @title Coder API diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index 2cef1ab74b71d..8de475c784ef3 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -145,7 +145,6 @@ type Options struct { WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions AllowWorkspaceRenames bool - AllowWorkspaceRenamesExpiresAt time.Time } // New constructs a codersdk client connected to an in-memory API instance. @@ -399,10 +398,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can derpMap, err := tailnet.NewDERPMap(ctx, region, stunAddresses, "", "", options.DeploymentValues.DERP.Config.BlockDirect.Value()) require.NoError(t, err) - if options.AllowWorkspaceRenamesExpiresAt.IsZero() { - options.AllowWorkspaceRenamesExpiresAt = time.Now().Add(time.Hour) - } - return func(h http.Handler) { mutex.Lock() defer mutex.Unlock() @@ -456,7 +451,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can StatsBatcher: options.StatsBatcher, WorkspaceAppsStatsCollectorOptions: options.WorkspaceAppsStatsCollectorOptions, AllowWorkspaceRenames: options.AllowWorkspaceRenames, - AllowWorkspaceRenamesExpiresAt: options.AllowWorkspaceRenamesExpiresAt, } } diff --git a/coderd/workspaces.go b/coderd/workspaces.go index 2f3cb21363a82..8d4cba7a40087 100644 --- a/coderd/workspaces.go +++ b/coderd/workspaces.go @@ -637,12 +637,6 @@ func (api *API) patchWorkspace(rw http.ResponseWriter, r *http.Request) { }) return } - if api.Options.AllowWorkspaceRenamesExpiresAt.Before(time.Now()) { - httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ - Message: "Workspace renames are no longer allowed. Flag expired at " + api.Options.AllowWorkspaceRenamesExpiresAt.String(), - }) - return - } name = req.Name } diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index d8becc2be8b99..69ab38d8cabb9 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -160,30 +160,6 @@ func TestWorkspace(t *testing.T) { require.ErrorContains(t, err, "Workspace renames are not allowed") }) - t.Run("RenameExpired", func(t *testing.T) { - t.Parallel() - client := coderdtest.New(t, &coderdtest.Options{ - IncludeProvisionerDaemon: true, - AllowWorkspaceRenames: true, - AllowWorkspaceRenamesExpiresAt: time.Now().Add(-1 * time.Hour), - }) - user := coderdtest.CreateFirstUser(t, client) - version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) - coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) - template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID) - ws1 := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID) - coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws1.LatestBuild.ID) - - ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) - defer cancel() - - want := "new-name" - err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{ - Name: want, - }) - require.ErrorContains(t, err, "Workspace renames are no longer allowed") - }) - t.Run("TemplateProperties", func(t *testing.T) { t.Parallel() client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 433db33b43337..c0aefa2795768 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "flag" + "fmt" "net/http" "os" "path/filepath" @@ -1845,7 +1846,7 @@ Write out the current server config as YAML to stdout.`, }, { Name: "Allow Workspace Renames", - Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01.", + Description: fmt.Sprintf("DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after %s.", WorkspaceRenameDeadline.Format("2006-01-02")), Flag: "allow-workspace-renames", Env: "CODER_ALLOW_WORKSPACE_RENAMES", Default: "false", diff --git a/codersdk/workspaces.go b/codersdk/workspaces.go index 59dede325ee0b..a7550eb554e9f 100644 --- a/codersdk/workspaces.go +++ b/codersdk/workspaces.go @@ -21,6 +21,8 @@ const ( AutomaticUpdatesNever AutomaticUpdates = "never" ) +var WorkspaceRenameDeadline = time.Date(2024, 04, 01, 0, 0, 0, 0, time.UTC) + // Workspace is a deployment of a template. It references a specific // version and can be updated. type Workspace struct { From f9bd7c2834da675f620408b65384512bdb3febac Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 13:46:13 +0000 Subject: [PATCH 14/24] remove time component --- cli/server.go | 8 +------- codersdk/deployment.go | 3 +-- codersdk/workspaces.go | 2 -- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/cli/server.go b/cli/server.go index 7861383e12c9f..2caf9f891286d 100644 --- a/cli/server.go +++ b/cli/server.go @@ -583,9 +583,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. HostnamePrefix: vals.SSHConfig.DeploymentName.String(), SSHConfigOptions: configSSHOptions, }, - // we are experimenting with self destructing flags that stop working after a certain date. - // This flag should be removed after the date specified below. - AllowWorkspaceRenames: allowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()), + AllowWorkspaceRenames: vals.AllowWorkspaceRenames.Value(), } if httpServers.TLSConfig != nil { options.TLSCertificates = httpServers.TLSConfig.Certificates @@ -2551,7 +2549,3 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder } return providers, nil } - -func allowWorkspaceRenames(flagValue bool) bool { - return flagValue && time.Now().Before(codersdk.WorkspaceRenameDeadline) -} diff --git a/codersdk/deployment.go b/codersdk/deployment.go index c0aefa2795768..4e7a1e7116ac3 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "flag" - "fmt" "net/http" "os" "path/filepath" @@ -1846,7 +1845,7 @@ Write out the current server config as YAML to stdout.`, }, { Name: "Allow Workspace Renames", - Description: fmt.Sprintf("DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after %s.", WorkspaceRenameDeadline.Format("2006-01-02")), + Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons.", Flag: "allow-workspace-renames", Env: "CODER_ALLOW_WORKSPACE_RENAMES", Default: "false", diff --git a/codersdk/workspaces.go b/codersdk/workspaces.go index a7550eb554e9f..59dede325ee0b 100644 --- a/codersdk/workspaces.go +++ b/codersdk/workspaces.go @@ -21,8 +21,6 @@ const ( AutomaticUpdatesNever AutomaticUpdates = "never" ) -var WorkspaceRenameDeadline = time.Date(2024, 04, 01, 0, 0, 0, 0, time.UTC) - // Workspace is a deployment of a template. It references a specific // version and can be updated. type Workspace struct { From db340756e09a7b0e7bf5ce29882c61d143dfc583 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 13:53:22 +0000 Subject: [PATCH 15/24] make gen --- cli/testdata/coder_server_--help.golden | 3 +-- cli/testdata/server-config.yaml.golden | 12 +----------- docs/cli/server.md | 9 ++------- enterprise/cli/testdata/coder_server_--help.golden | 3 +-- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index 5deee037497bf..042cc01563c9c 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -16,8 +16,7 @@ SUBCOMMANDS: OPTIONS: --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) DEPRECATED: Allow users to rename their workspaces. Use only for - temporary compatibility reasons, this flag will no longer function - after 2024-04-01. + temporary compatibility reasons. --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index 454d096227f59..7b1d23e8e0a64 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -450,7 +450,6 @@ wgtunnelHost: "" userQuietHoursSchedule: # The default daily cron schedule applied to users that haven't set a custom quiet # hours schedule themselves. The quiet hours schedule determines when workspaces -<<<<<<< HEAD # will be force stopped due to the template's autostop requirement, and will round # the max deadline up to be within the user's quiet hours window (or default). The # format is the same as the standard cron format, but the day-of-month, month and @@ -463,16 +462,7 @@ userQuietHoursSchedule: # change their quiet hours schedule and the site default is always used. # (default: true, type: bool) allowCustomQuietHours: true -======= - # will be force stopped due to the template's max TTL, and will round the max TTL - # up to be within the user's quiet hours window (or default). The format is the - # same as the standard cron format, but the day-of-month, month and day-of-week - # must be *. Only one hour and minute can be specified (ranges or comma separated - # values are not supported). - # (default: , type: string) - defaultQuietHoursSchedule: "" # DEPRECATED: Allow users to rename their workspaces. Use only for temporary -# compatibility reasons, this flag will no longer function after 2024-04-01. +# compatibility reasons. # (default: false, type: bool) allowWorkspaceRenames: false ->>>>>>> 899e802d6 (update golden) diff --git a/docs/cli/server.md b/docs/cli/server.md index c89ce2b11931b..32e3764fee5e0 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -31,7 +31,6 @@ coder server [flags] The URL that users will use to access the Coder deployment. -<<<<<<< HEAD ### --allow-custom-quiet-hours | | | @@ -42,7 +41,7 @@ The URL that users will use to access the Coder deployment. | Default | true | Allow users to set their own quiet hours schedule for workspaces to stop in (depending on template autostop requirement settings). If false, users can't change their quiet hours schedule and the site default is always used. -======= + ### --allow-workspace-renames | | | @@ -52,11 +51,7 @@ Allow users to set their own quiet hours schedule for workspaces to stop in (dep | YAML | allowWorkspaceRenames | | Default | false | - -Allow users to rename their workspaces. This is not recommended for production deployments as it can cause issues with the workspace's internal state. Use only for compatibility reasons. - -DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01T00:00:00Z00:00. - +DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons. ### --block-direct-connections diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index 7cf8dd21f6d75..2801328e7c1ce 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -17,8 +17,7 @@ SUBCOMMANDS: OPTIONS: --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) DEPRECATED: Allow users to rename their workspaces. Use only for - temporary compatibility reasons, this flag will no longer function - after 2024-04-01. + temporary compatibility reasons. --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and From 7856e82812ea92cda2b33b67fbc5d1219b6c47cb Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 14:25:55 +0000 Subject: [PATCH 16/24] properly disable form --- .../WorkspaceSettingsForm.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index acc7bfb3e134f..8de3acee52aca 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -34,6 +34,9 @@ export const WorkspaceSettingsForm: FC<{ onCancel: () => void; onSubmit: (values: WorkspaceSettingsFormValues) => Promise; }> = ({ onCancel, onSubmit, workspace, error, templatePoliciesEnabled }) => { + const formEnabled = (templatePoliciesEnabled && !workspace.template_require_active_version) + || workspace.allow_renames + const form = useFormik({ onSubmit, initialValues: { @@ -54,7 +57,7 @@ export const WorkspaceSettingsForm: FC<{ )} - + {formEnabled && ( + + )} ); }; From 6a3a9e72a96dce259c9b662ea50f40ebd2349802 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 14:27:35 +0000 Subject: [PATCH 17/24] add helper text --- .../src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 8de3acee52aca..cb1e6ec656546 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -67,6 +67,10 @@ export const WorkspaceSettingsForm: FC<{ autoFocus fullWidth label="Name" + helperText={ + !workspace.allow_renames && + "Renaming your workspace can be destructive and are not allowed." + } /> {form.values.name !== form.initialValues.name && ( From 8f96b3d865446d0e2aa260f6ee9539aeeeb772e9 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 14:31:29 +0000 Subject: [PATCH 18/24] make fmt --- .../pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index cb1e6ec656546..19dac8f91e130 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -34,8 +34,9 @@ export const WorkspaceSettingsForm: FC<{ onCancel: () => void; onSubmit: (values: WorkspaceSettingsFormValues) => Promise; }> = ({ onCancel, onSubmit, workspace, error, templatePoliciesEnabled }) => { - const formEnabled = (templatePoliciesEnabled && !workspace.template_require_active_version) - || workspace.allow_renames + const formEnabled = + (templatePoliciesEnabled && !workspace.template_require_active_version) || + workspace.allow_renames; const form = useFormik({ onSubmit, From aef681432ab570c251411e6b478b4688d88ec4cd Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 14:40:34 +0000 Subject: [PATCH 19/24] correct submit logic --- .../WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 19dac8f91e130..0cf6afbea04be 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -35,7 +35,7 @@ export const WorkspaceSettingsForm: FC<{ onSubmit: (values: WorkspaceSettingsFormValues) => Promise; }> = ({ onCancel, onSubmit, workspace, error, templatePoliciesEnabled }) => { const formEnabled = - (templatePoliciesEnabled && !workspace.template_require_active_version) || + (!templatePoliciesEnabled && !workspace.template_require_active_version) || workspace.allow_renames; const form = useFormik({ @@ -81,7 +81,7 @@ export const WorkspaceSettingsForm: FC<{ )} - {templatePoliciesEnabled && ( + {!templatePoliciesEnabled && ( )} {formEnabled && ( - + )} ); From a64208682c6638d401a53dcb8bee0ce02127fc0f Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 14:42:26 +0000 Subject: [PATCH 20/24] fix mistake --- .../src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 0cf6afbea04be..8d3a091b988dc 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -35,7 +35,7 @@ export const WorkspaceSettingsForm: FC<{ onSubmit: (values: WorkspaceSettingsFormValues) => Promise; }> = ({ onCancel, onSubmit, workspace, error, templatePoliciesEnabled }) => { const formEnabled = - (!templatePoliciesEnabled && !workspace.template_require_active_version) || + (templatePoliciesEnabled && !workspace.template_require_active_version) || workspace.allow_renames; const form = useFormik({ @@ -81,7 +81,7 @@ export const WorkspaceSettingsForm: FC<{ )} - {!templatePoliciesEnabled && ( + {templatePoliciesEnabled && ( Date: Fri, 15 Dec 2023 15:00:58 +0000 Subject: [PATCH 21/24] pr comment wording --- codersdk/deployment.go | 2 +- site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 4e7a1e7116ac3..54b67f127907d 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -1845,7 +1845,7 @@ Write out the current server config as YAML to stdout.`, }, { Name: "Allow Workspace Renames", - Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons.", + Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this will be removed in a future release.", Flag: "allow-workspace-renames", Env: "CODER_ALLOW_WORKSPACE_RENAMES", Default: "false", diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 8d3a091b988dc..3e8d2a5590122 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -70,7 +70,7 @@ export const WorkspaceSettingsForm: FC<{ label="Name" helperText={ !workspace.allow_renames && - "Renaming your workspace can be destructive and are not allowed." + "Renaming your workspace can be destructive and has not been enabled for this deployment." } /> {form.values.name !== form.initialValues.name && ( From 57a55884b5dd480d18b2c5828000298ba95f0429 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 16:15:55 +0000 Subject: [PATCH 22/24] update golden --- cli/testdata/coder_server_--help.golden | 3 ++- cli/testdata/server-config.yaml.golden | 2 +- docs/cli/server.md | 2 +- enterprise/cli/testdata/coder_server_--help.golden | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index 042cc01563c9c..5f8cd85a84e2f 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -16,7 +16,8 @@ SUBCOMMANDS: OPTIONS: --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) DEPRECATED: Allow users to rename their workspaces. Use only for - temporary compatibility reasons. + temporary compatibility reasons, this will be removed in a future + release. --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index 7b1d23e8e0a64..5abf74e675e68 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -463,6 +463,6 @@ userQuietHoursSchedule: # (default: true, type: bool) allowCustomQuietHours: true # DEPRECATED: Allow users to rename their workspaces. Use only for temporary -# compatibility reasons. +# compatibility reasons, this will be removed in a future release. # (default: false, type: bool) allowWorkspaceRenames: false diff --git a/docs/cli/server.md b/docs/cli/server.md index 32e3764fee5e0..a0c4aad6e97ba 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -51,7 +51,7 @@ Allow users to set their own quiet hours schedule for workspaces to stop in (dep | YAML | allowWorkspaceRenames | | Default | false | -DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons. +DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this will be removed in a future release. ### --block-direct-connections diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index 2801328e7c1ce..0df1bec5bb35d 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -17,7 +17,8 @@ SUBCOMMANDS: OPTIONS: --allow-workspace-renames bool, $CODER_ALLOW_WORKSPACE_RENAMES (default: false) DEPRECATED: Allow users to rename their workspaces. Use only for - temporary compatibility reasons. + temporary compatibility reasons, this will be removed in a future + release. --cache-dir string, $CODER_CACHE_DIRECTORY (default: [cache dir]) The directory to cache temporary files. If unspecified and From b8c12f882e33397e766cf93aeb05f34d6bb5dcb8 Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 17:04:23 +0000 Subject: [PATCH 23/24] frontend cleanup --- .../WorkspaceSettingsForm.tsx | 22 +++++++++++-------- .../WorkspaceSettingsPage.test.tsx | 20 ++++++++++++++++- .../WorkspaceSettingsPageView.stories.tsx | 6 +++++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 3e8d2a5590122..25fd79e7b7adc 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -18,9 +18,9 @@ import { AutomaticUpdateses, Workspace, } from "api/typesGenerated"; -import { Alert } from "components/Alert/Alert"; import MenuItem from "@mui/material/MenuItem"; import upperFirst from "lodash/upperFirst"; +import { type Theme } from "@emotion/react"; export type WorkspaceSettingsFormValues = { name: string; @@ -58,7 +58,7 @@ export const WorkspaceSettingsForm: FC<{ - {form.values.name !== form.initialValues.name && ( - - Depending on the template, renaming your workspace may be - destructive - - )} {templatePoliciesEnabled && ( @@ -120,3 +116,11 @@ export const WorkspaceSettingsForm: FC<{ ); }; + +const styles = { + nameWarning: (theme: Theme) => ({ + "& .MuiFormHelperText-root": { + color: theme.palette.warning.light + }, + }) +} diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx index 0aaa510857e8e..2457ec5d4470d 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx @@ -12,7 +12,7 @@ test("Submit the workspace settings page successfully", async () => { // Mock the API calls that loads data jest .spyOn(api, "getWorkspaceByOwnerAndName") - .mockResolvedValueOnce(MockWorkspace); + .mockResolvedValueOnce({...MockWorkspace,}); // Mock the API calls that submit data const patchWorkspaceSpy = jest .spyOn(api, "patchWorkspace") @@ -39,3 +39,21 @@ test("Submit the workspace settings page successfully", async () => { }); }); }); + +test("Name field is disabled if renames are disabled", async () => { + // Mock the API calls that loads data + jest + .spyOn(api, "getWorkspaceByOwnerAndName") + .mockResolvedValueOnce({...MockWorkspace, allow_renames: false}); + renderWithWorkspaceSettingsLayout(, { + route: "/@test-user/test-workspace/settings", + path: "/:username/:workspace/settings", + // Need this because after submit the user is redirected + extraRoutes: [{ path: "/:username/:workspace", element:
}], + }); + await waitForLoaderToBeRemoved(); + // Fill the form and submit + const form = screen.getByTestId("form"); + const name = within(form).getByLabelText("Name"); + expect(name).toBeDisabled(); +}); diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx index 1a316b4bb9488..c30b725434c66 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx @@ -21,3 +21,9 @@ export const AutoUpdates: Story = { templatePoliciesEnabled: true, }, }; + +export const RenamesDisabled: Story = { + args: { + workspace: {...MockWorkspace, allow_renames: false} + }, +}; From f69ccda7c76a14e6401bc5f94b2f12c19af5965a Mon Sep 17 00:00:00 2001 From: Garrett Delfosse Date: Fri, 15 Dec 2023 17:04:58 +0000 Subject: [PATCH 24/24] make fmt --- .../WorkspaceSettingsPage/WorkspaceSettingsForm.tsx | 13 +++++++------ .../WorkspaceSettingsPage.test.tsx | 4 ++-- .../WorkspaceSettingsPageView.stories.tsx | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx index 25fd79e7b7adc..824d47460ab55 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsForm.tsx @@ -70,9 +70,10 @@ export const WorkspaceSettingsForm: FC<{ label="Name" css={workspace.allow_renames && styles.nameWarning} helperText={ - workspace.allow_renames ? - form.values.name !== form.initialValues.name && "Depending on the template, renaming your workspace may be destructive" : - "Renaming your workspace can be destructive and has not been enabled for this deployment." + workspace.allow_renames + ? form.values.name !== form.initialValues.name && + "Depending on the template, renaming your workspace may be destructive" + : "Renaming your workspace can be destructive and has not been enabled for this deployment." } /> @@ -120,7 +121,7 @@ export const WorkspaceSettingsForm: FC<{ const styles = { nameWarning: (theme: Theme) => ({ "& .MuiFormHelperText-root": { - color: theme.palette.warning.light + color: theme.palette.warning.light, }, - }) -} + }), +}; diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx index 2457ec5d4470d..d6d8c9a11c1f8 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPage.test.tsx @@ -12,7 +12,7 @@ test("Submit the workspace settings page successfully", async () => { // Mock the API calls that loads data jest .spyOn(api, "getWorkspaceByOwnerAndName") - .mockResolvedValueOnce({...MockWorkspace,}); + .mockResolvedValueOnce({ ...MockWorkspace }); // Mock the API calls that submit data const patchWorkspaceSpy = jest .spyOn(api, "patchWorkspace") @@ -44,7 +44,7 @@ test("Name field is disabled if renames are disabled", async () => { // Mock the API calls that loads data jest .spyOn(api, "getWorkspaceByOwnerAndName") - .mockResolvedValueOnce({...MockWorkspace, allow_renames: false}); + .mockResolvedValueOnce({ ...MockWorkspace, allow_renames: false }); renderWithWorkspaceSettingsLayout(, { route: "/@test-user/test-workspace/settings", path: "/:username/:workspace/settings", diff --git a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx index c30b725434c66..41c2633473be0 100644 --- a/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx +++ b/site/src/pages/WorkspaceSettingsPage/WorkspaceSettingsPageView.stories.tsx @@ -24,6 +24,6 @@ export const AutoUpdates: Story = { export const RenamesDisabled: Story = { args: { - workspace: {...MockWorkspace, allow_renames: false} + workspace: { ...MockWorkspace, allow_renames: false }, }, };