Skip to content

Commit 4da4093

Browse files
committed
address pr comments
1 parent 691b8c5 commit 4da4093

File tree

7 files changed

+9
-55
lines changed

7 files changed

+9
-55
lines changed

cli/server.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
585585
},
586586
// we are experimenting with self destructing flags that stop working after a certain date.
587587
// This flag should be removed after the date specified below.
588-
AllowWorkspaceRenames: shouldAllowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()),
589-
AllowWorkspaceRenamesExpiresAt: workspaceRenamesExpiresAt(),
588+
AllowWorkspaceRenames: allowWorkspaceRenames(vals.AllowWorkspaceRenames.Value()),
590589
}
591590
if httpServers.TLSConfig != nil {
592591
options.TLSCertificates = httpServers.TLSConfig.Certificates
@@ -2553,19 +2552,6 @@ func parseExternalAuthProvidersFromEnv(prefix string, environ []string) ([]coder
25532552
return providers, nil
25542553
}
25552554

2556-
const (
2557-
workspaceRenamesExpiresAtTime = "2024-04-01T00:00:00Z"
2558-
)
2559-
2560-
func workspaceRenamesExpiresAt() time.Time {
2561-
t, err := time.Parse(time.RFC3339, workspaceRenamesExpiresAtTime)
2562-
if err != nil {
2563-
panic(err)
2564-
}
2565-
2566-
return t
2567-
}
2568-
2569-
func shouldAllowWorkspaceRenames(value bool) bool {
2570-
return value && time.Now().Before(workspaceRenamesExpiresAt())
2555+
func allowWorkspaceRenames(flagValue bool) bool {
2556+
return flagValue && time.Now().Before(codersdk.WorkspaceRenameDeadline)
25712557
}

coderd/coderd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ type Options struct {
179179
// This janky function is used in telemetry to parse fields out of the raw
180180
// JWT. It needs to be passed through like this because license parsing is
181181
// under the enterprise license, and can't be imported into AGPL.
182-
ParseLicenseClaims func(rawJWT string) (email string, trial bool, err error)
182+
ParseLicenseClaims func(rawJWT string) (email string, trial bool, err error)
183+
AllowWorkspaceRenames bool
183184
}
184185

185186
// @title Coder API

coderd/coderdtest/coderdtest.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ type Options struct {
145145

146146
WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions
147147
AllowWorkspaceRenames bool
148-
AllowWorkspaceRenamesExpiresAt time.Time
149148
}
150149

151150
// 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
399398
derpMap, err := tailnet.NewDERPMap(ctx, region, stunAddresses, "", "", options.DeploymentValues.DERP.Config.BlockDirect.Value())
400399
require.NoError(t, err)
401400

402-
if options.AllowWorkspaceRenamesExpiresAt.IsZero() {
403-
options.AllowWorkspaceRenamesExpiresAt = time.Now().Add(time.Hour)
404-
}
405-
406401
return func(h http.Handler) {
407402
mutex.Lock()
408403
defer mutex.Unlock()
@@ -456,7 +451,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
456451
StatsBatcher: options.StatsBatcher,
457452
WorkspaceAppsStatsCollectorOptions: options.WorkspaceAppsStatsCollectorOptions,
458453
AllowWorkspaceRenames: options.AllowWorkspaceRenames,
459-
AllowWorkspaceRenamesExpiresAt: options.AllowWorkspaceRenamesExpiresAt,
460454
}
461455
}
462456

coderd/workspaces.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -637,12 +637,6 @@ func (api *API) patchWorkspace(rw http.ResponseWriter, r *http.Request) {
637637
})
638638
return
639639
}
640-
if api.Options.AllowWorkspaceRenamesExpiresAt.Before(time.Now()) {
641-
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
642-
Message: "Workspace renames are no longer allowed. Flag expired at " + api.Options.AllowWorkspaceRenamesExpiresAt.String(),
643-
})
644-
return
645-
}
646640
name = req.Name
647641
}
648642

coderd/workspaces_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,6 @@ func TestWorkspace(t *testing.T) {
160160
require.ErrorContains(t, err, "Workspace renames are not allowed")
161161
})
162162

163-
t.Run("RenameExpired", func(t *testing.T) {
164-
t.Parallel()
165-
client := coderdtest.New(t, &coderdtest.Options{
166-
IncludeProvisionerDaemon: true,
167-
AllowWorkspaceRenames: true,
168-
AllowWorkspaceRenamesExpiresAt: time.Now().Add(-1 * time.Hour),
169-
})
170-
user := coderdtest.CreateFirstUser(t, client)
171-
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
172-
coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID)
173-
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
174-
ws1 := coderdtest.CreateWorkspace(t, client, user.OrganizationID, template.ID)
175-
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, ws1.LatestBuild.ID)
176-
177-
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
178-
defer cancel()
179-
180-
want := "new-name"
181-
err := client.UpdateWorkspace(ctx, ws1.ID, codersdk.UpdateWorkspaceRequest{
182-
Name: want,
183-
})
184-
require.ErrorContains(t, err, "Workspace renames are no longer allowed")
185-
})
186-
187163
t.Run("TemplateProperties", func(t *testing.T) {
188164
t.Parallel()
189165
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})

codersdk/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"flag"
7+
"fmt"
78
"net/http"
89
"os"
910
"path/filepath"
@@ -1845,7 +1846,7 @@ Write out the current server config as YAML to stdout.`,
18451846
},
18461847
{
18471848
Name: "Allow Workspace Renames",
1848-
Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01.",
1849+
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")),
18491850
Flag: "allow-workspace-renames",
18501851
Env: "CODER_ALLOW_WORKSPACE_RENAMES",
18511852
Default: "false",

codersdk/workspaces.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121
AutomaticUpdatesNever AutomaticUpdates = "never"
2222
)
2323

24+
var WorkspaceRenameDeadline = time.Date(2024, 04, 01, 0, 0, 0, 0, time.UTC)
25+
2426
// Workspace is a deployment of a template. It references a specific
2527
// version and can be updated.
2628
type Workspace struct {

0 commit comments

Comments
 (0)