- Notifications
You must be signed in to change notification settings - Fork913
feat(coderd): enable setting max port share level during template creation#14366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -163,6 +163,7 @@ func (api *API) notifyTemplateDeleted(ctx context.Context, template database.Tem | ||
func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Request) { | ||
var ( | ||
ctx = r.Context() | ||
portSharer = *api.PortSharer.Load() | ||
createTemplate codersdk.CreateTemplateRequest | ||
organization = httpmw.OrganizationParam(r) | ||
apiKey = httpmw.APIKey(r) | ||
@@ -309,6 +310,7 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque | ||
validErrs []codersdk.ValidationError | ||
autostopRequirementDaysOfWeekParsed uint8 | ||
autostartRequirementDaysOfWeekParsed uint8 | ||
maxPortShareLevel = database.AppSharingLevelOwner // default | ||
) | ||
if defaultTTL < 0 { | ||
validErrs = append(validErrs, codersdk.ValidationError{Field: "default_ttl_ms", Detail: "Must be a positive integer."}) | ||
@@ -329,6 +331,14 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque | ||
validErrs = append(validErrs, codersdk.ValidationError{Field: "autostart_requirement.days_of_week", Detail: err.Error()}) | ||
} | ||
} | ||
if createTemplate.MaxPortShareLevel != nil { | ||
err = portSharer.ValidateTemplateMaxLevel(*createTemplate.MaxPortShareLevel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Of note is that this will always error for AGPL deployments. | ||
if err != nil { | ||
validErrs = append(validErrs, codersdk.ValidationError{Field: "max_port_share_level", Detail: err.Error()}) | ||
} else { | ||
maxPortShareLevel = database.AppSharingLevel(*createTemplate.MaxPortShareLevel) | ||
} | ||
} | ||
if autostopRequirementWeeks < 0 { | ||
validErrs = append(validErrs, codersdk.ValidationError{Field: "autostop_requirement.weeks", Detail: "Must be a positive integer."}) | ||
@@ -386,7 +396,7 @@ func (api *API) postTemplateByOrganization(rw http.ResponseWriter, r *http.Reque | ||
DisplayName: createTemplate.DisplayName, | ||
Icon: createTemplate.Icon, | ||
AllowUserCancelWorkspaceJobs: allowUserCancelWorkspaceJobs, | ||
MaxPortSharingLevel:maxPortShareLevel, | ||
}) | ||
if err != nil { | ||
return xerrors.Errorf("insert template: %s", err) | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.