Skip to content

fix: make template push a superset of template create #11299

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 19 commits into from
Prev Previous commit
Next Next commit
add groupacl
  • Loading branch information
f0ssel committed Jan 2, 2024
commit 06618d7613702c71be12a28da16716341bb325bf
2 changes: 1 addition & 1 deletion cli/templatepush.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
}
req := codersdk.UpdateTemplateMeta{
RequireActiveVersion: requireActiveVersion,
DisableEveryone: disableEveryone,
DisableEveryoneGroupAccess: disableEveryone,
DefaultTTLMillis: defaultTTL.Milliseconds(),
FailureTTLMillis: failureTTL.Milliseconds(),
TimeTilDormantMillis: dormancyThreshold.Milliseconds(),
Expand Down
19 changes: 11 additions & 8 deletions coderd/database/queries.sql.go

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

3 changes: 2 additions & 1 deletion coderd/database/queries/templates.sql
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ SET
name = $4,
icon = $5,
display_name = $6,
allow_user_cancel_workspace_jobs = $7
allow_user_cancel_workspace_jobs = $7,
group_acl = $8
WHERE
id = $1
;
Expand Down
6 changes: 6 additions & 0 deletions coderd/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,11 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
name = template.Name
}

groupACL := template.GroupACL
if req.DisableEveryoneGroupAccess {
groupACL = database.TemplateACL{}
}

var err error
err = tx.UpdateTemplateMetaByID(ctx, database.UpdateTemplateMetaByIDParams{
ID: template.ID,
Expand All @@ -676,6 +681,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
Description: req.Description,
Icon: req.Icon,
AllowUserCancelWorkspaceJobs: req.AllowUserCancelWorkspaceJobs,
GroupACL: groupACL,
})
if err != nil {
return xerrors.Errorf("update template metadata: %w", err)
Expand Down
6 changes: 6 additions & 0 deletions codersdk/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ type UpdateTemplateMeta struct {
// If passed an empty string, will remove the deprecated message, making
// the template usable for new workspaces again.
DeprecationMessage *string `json:"deprecation_message"`
// DisableEveryoneGroupAccess allows optionally disabling the default
// behavior of granting the 'everyone' group access to use the template.
// If this is set to true, the template will not be available to all users,
// and must be explicitly granted to users or groups in the permissions settings
// of the template.
DisableEveryoneGroupAccess bool `json:"disable_everyone_group_access"`
}

type TemplateExample struct {
Expand Down
64 changes: 58 additions & 6 deletions docs/cli/templates_push.md

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

1 change: 1 addition & 0 deletions site/src/api/typesGenerated.ts

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