8000 address pr comments · coder/coder@6286cf2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6286cf2

Browse files
committed
address pr comments
1 parent 8975ed1 commit 6286cf2

File tree

7 files changed

+7
-55
lines changed

7 files changed

+7
-55
lines changed

cli/server.go

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

2539-
const (
2540-
workspaceRenamesExpiresAtTime = "2024-04-01T00:00:00Z"
2541-
)
2542-
2543-
func workspaceRenamesExpiresAt() time.Time {
2544-
t, err := time.Parse(time.RFC3339, workspaceRenamesExpiresAtTime)
2545-
if err != nil {
2546-
panic(err)
2547-
}
2548-
2549-
return t
2550-
}
2551-
2552-
func shouldAllowWorkspaceRenames(value bool) bool {
2553-
return value && time.Now().Before(workspaceRenamesExpiresAt())
2538+
func allowWorkspaceRenames(flagValue bool) bool {
2539+
return flagValue && time.Now().Before(codersdk.WorkspaceRenameDeadline)
25542540
}

coderd/coderd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ type Options struct {
173173

174174
WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions
175175
AllowWorkspaceRenames bool
176-
AllowWorkspaceRenamesExpiresAt time.Time
177176
}
178177

179178
// @title Coder API

coderd/coderdtest/coderdtest.go

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

145145
WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions
146146
AllowWorkspaceRenames bool
147-
AllowWorkspaceRenamesExpiresAt time.Time
148147
}
149148

150149
// New constructs a codersdk client connected to an in-memory API instance.
@@ -398,10 +397,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
398397
derpMap, err := tailnet.NewDERPMap(ctx, region, stunAddresses, "", "", options.DeploymentValues.DERP.Config.BlockDirect.Value())
399398
require.NoError(t, err)
400399

401-
if options.AllowWorkspaceRenamesExpiresAt.IsZero() {
402-
options.AllowWorkspaceRenamesExpiresAt = time.Now().Add(time.Hour)
403-
}
404-
405400
return func(h http.Handler) {
406401
mutex.Lock()
407402
defer mutex.Unlock()
@@ -455,7 +450,6 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
455450
StatsBatcher: options.StatsBatcher,
456451
WorkspaceAppsStatsCollectorOptions: options.WorkspaceAppsStatsCollectorOptions,
457452
AllowWorkspaceRenames: options.AllowWorkspaceRenames,
458-
AllowWorkspaceRenamesExpiresAt: options.AllowWorkspaceRenamesExpiresAt,
459453
}
460454
}
461455

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"
@@ -1837,7 +1838,7 @@ Write out the current server config as YAML to stdout.`,
18371838
},
18381839
{
18391840
Name: "Allow Workspace Renames",
1840-
Description: "DEPRECATED: Allow users to rename their workspaces. Use only for temporary compatibility reasons, this flag will no longer function after 2024-04-01.",
1841+
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")),
18411842
Flag: "allow-workspace-renames",
18421843
Env: "CODER_ALLOW_WORKSPACE_RENAMES",
18431844
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)
0