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
chore: add switching template flow from api
  • Loading branch information
Emyrk committed May 14, 2025
commit e1e2af8bd03f36c868b21018e3972f1b785720c2
1 change: 1 addition & 0 deletions coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ func (api *API) convertTemplate(
Deprecated: templateAccessControl.IsDeprecated(),
DeprecationMessage: templateAccessControl.Deprecated,
MaxPortShareLevel: maxPortShareLevel,
ClassicParameterFlow: template.ClassicParameterFlow,
}
}

Expand Down
35 changes: 35 additions & 0 deletions coderd/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1540,6 +1540,41 @@ func TestPatchTemplateMeta(t *testing.T) {
require.False(t, template.Deprecated)
})
})

t.Run("ClassicParameterFlow", func(t *testing.T) {
t.Parallel()

client := coderdtest.New(t, nil)
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")

bTrue := true
bFalse := false
req := codersdk.UpdateTemplateMeta{
ClassicParameterFlow: &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")

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

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

func TestDeleteTemplate(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions codersdk/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Template struct {
// template version.
RequireActiveVersion bool `json:"require_active_version"`
MaxPortShareLevel WorkspaceAgentPortShareLevel `json:"max_port_share_level"`

ClassicParameterFlow bool `json:"classic_parameter_flow"`
}

// WeekdaysToBitmap converts a list of weekdays to a bitmap in accordance with
Expand Down
Loading