feat: support dynamic parameters on create template request (#18636)

Future work is to add this checkbox to the UI to opt into dynamic
parameters from the first template create.
This commit is contained in:
Steven Masley
2025-07-02 09:44:01 -05:00
committed by GitHub
parent 91aa583ea4
commit 4072d228c5
13 changed files with 72 additions and 40 deletions

View File

@ -197,16 +197,20 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
return
}
// Default is true until dynamic parameters are promoted to stable.
useClassicParameterFlow := ptr.NilToDefault(createTemplate.UseClassicParameterFlow, true)
// Make a temporary struct to represent the template. This is used for
// auditing if any of the following checks fail. It will be overwritten when
// the template is inserted into the db.
templateAudit.New = database.Template{
OrganizationID: organization.ID,
Name: createTemplate.Name,
Description: createTemplate.Description,
CreatedBy: apiKey.UserID,
Icon: createTemplate.Icon,
DisplayName: createTemplate.DisplayName,
OrganizationID: organization.ID,
Name: createTemplate.Name,
Description: createTemplate.Description,
CreatedBy: apiKey.UserID,
Icon: createTemplate.Icon,
DisplayName: createTemplate.DisplayName,
UseClassicParameterFlow: useClassicParameterFlow,
}
_, err := api.Database.GetTemplateByOrganizationAndName(ctx, database.GetTemplateByOrganizationAndNameParams{
@ -404,6 +408,7 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque
Icon: createTemplate.Icon,
AllowUserCancelWorkspaceJobs: allowUserCancelWorkspaceJobs,
MaxPortSharingLevel: maxPortShareLevel,
UseClassicParameterFlow: useClassicParameterFlow,
})
if err != nil {
return xerrors.Errorf("insert template: %s", err)