Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Finalize rename
  • Loading branch information
Emyrk committed May 14, 2025
commit 9674d07a95df78ad2542443a6fbdb5555bc4c268
6 changes: 3 additions & 3 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -11083,7 +11083,7 @@ func (q *FakeQuerier) UpdateTemplateMetaByID(_ context.Context, arg database.Upd
tpl.GroupACL = arg.GroupACL
tpl.AllowUserCancelWorkspaceJobs = arg.AllowUserCancelWorkspaceJobs
tpl.MaxPortSharingLevel = arg.MaxPortSharingLevel
tpl.ClassicParameterFlow = arg.ClassicParameterFlow
tpl.UseClassicParameterFlow = arg.UseClassicParameterFlow
q.templates[idx] = tpl
return nil
}
Expand Down
659 changes: 659 additions & 0 deletions coderd/database/querier.go

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
}

// Defaults to the existing.
classicTemplateFlow := template.ClassicParameterFlow
if req.ClassicParameterFlow != nil {
classicTemplateFlow = *req.ClassicParameterFlow
classicTemplateFlow := template.UseClassicParameterFlow
if req.UseClassicParameterFlow != nil {
classicTemplateFlow = *req.UseClassicParameterFlow
}

var updated database.Template
Expand All @@ -753,7 +753,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
req.TimeTilDormantAutoDeleteMillis == time.Duration(template.TimeTilDormantAutoDelete).Milliseconds() &&
req.RequireActiveVersion == template.RequireActiveVersion &&
(deprecationMessage == template.Deprecated) &&
(classicTemplateFlow == template.ClassicParameterFlow) &&
(classicTemplateFlow == template.UseClassicParameterFlow) &&
maxPortShareLevel == template.MaxPortSharingLevel {
return nil
}
Expand Down Expand Up @@ -795,7 +795,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
AllowUserCancelWorkspaceJobs: req.AllowUserCancelWorkspaceJobs,
GroupACL: groupACL,
MaxPortSharingLevel: maxPortShareLevel,
ClassicParameterFlow: classicTemplateFlow,
UseClassicParameterFlow: classicTemplateFlow,
})
if err != nil {
return xerrors.Errorf("update template metadata: %w", err)
Expand Down Expand Up @@ -1074,11 +1074,11 @@ func (api *API) convertTemplate(
DaysOfWeek: codersdk.BitmapToWeekdays(template.AutostartAllowedDays()),
},
// These values depend on entitlements and come from the templateAccessControl
RequireActiveVersion: templateAccessControl.RequireActiveVersion,
Deprecated: templateAccessControl.IsDeprecated(),
DeprecationMessage: templateAccessControl.Deprecated,
MaxPortShareLevel: maxPortShareLevel,
ClassicParameterFlow: template.ClassicParameterFlow,
RequireActiveVersion: templateAccessControl.RequireActiveVersion,
Deprecated: templateAccessControl.IsDeprecated(),
DeprecationMessage: templateAccessControl.Deprecated,
MaxPortShareLevel: maxPortShareLevel,
UseClassicParameterFlow: template.UseClassicParameterFlow,
}
}

Expand Down
14 changes: 7 additions & 7 deletions coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1548,32 +1548,32 @@ func TestPatchTemplateMeta(t *testing.T) {
user := coderdtest.CreateFirstUser(t, client)
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
require.False(t, template.ClassicParameterFlow, "default is false")
require.False(t, template.UseClassicParameterFlow, "default is false")

bTrue := true
bFalse := false
req := codersdk.UpdateTemplateMeta{
ClassicParameterFlow: &bTrue,
UseClassicParameterFlow: &bTrue,
}

ctx := testutil.Context(t, testutil.WaitLong)

// set to true
updated, err := client.UpdateTemplateMeta(ctx, template.ID, req)
require.NoError(t, err)
assert.True(t, updated.ClassicParameterFlow, "expected true")
assert.True(t, updated.UseClassicParameterFlow, "expected true")

// noop
req.ClassicParameterFlow = nil
req.UseClassicParameterFlow = nil
updated, err = client.UpdateTemplateMeta(ctx, template.ID, req)
require.NoError(t, err)
assert.True(t, updated.ClassicParameterFlow, "expected true")
assert.True(t, updated.UseClassicParameterFlow, "expected true")

// back to false
req.ClassicParameterFlow = &bFalse
req.UseClassicParameterFlow = &bFalse
updated, err = client.UpdateTemplateMeta(ctx, template.ID, req)
require.NoError(t, err)
assert.False(t, updated.ClassicParameterFlow, "expected false")
assert.False(t, updated.UseClassicParameterFlow, "expected false")
})
}

Expand Down
Loading
Loading