Skip to content

Commit 2e2d40a

Browse files
committed
add groupacl
1 parent 6e8b81c commit 2e2d40a

File tree

8 files changed

+86
-17
lines changed

8 files changed

+86
-17
lines changed

cli/templatepush.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (r *RootCmd) templatePush() *clibase.Cmd {
321321
}
322322
req := codersdk.UpdateTemplateMeta{
323323
RequireActiveVersion: requireActiveVersion,
324-
DisableEveryone: disableEveryone,
324+
DisableEveryoneGroupAccess: disableEveryone,
325325
DefaultTTLMillis: defaultTTL.Milliseconds(),
326326
FailureTTLMillis: failureTTL.Milliseconds(),
327327
TimeTilDormantMillis: dormancyThreshold.Milliseconds(),

coderd/database/dbauthz/setup_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/coder/coder/v2/coderd/util/slice"
2929
)
3030

31-
var errMatchAny = errors.New("match any error")
31+
var errMatchAny = xerrors.New("match any error")
3232

3333
var skipMethods = map[string]string{
3434
"InTx": "Not relevant",

coderd/database/queries.sql.go

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/templates.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ SET
115115
name = $4,
116116
icon = $5,
117117
display_name = $6,
118-
allow_user_cancel_workspace_jobs = $7
118+
allow_user_cancel_workspace_jobs = $7,
119+
group_acl = $8
119120
WHERE
120121
id = $1
121122
;

coderd/templates.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,11 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
667667
name = template.Name
668668
}
669669

670+
groupACL := template.GroupACL
671+
if req.DisableEveryoneGroupAccess {
672+
groupACL = database.TemplateACL{}
673+
}
674+
670675
var err error
671676
err = tx.UpdateTemplateMetaByID(ctx, database.UpdateTemplateMetaByIDParams{
672677
ID: template.ID,
@@ -676,6 +681,7 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) {
676681
Description: req.Description,
677682
Icon: req.Icon,
678683
AllowUserCancelWorkspaceJobs: req.AllowUserCancelWorkspaceJobs,
684+
GroupACL: groupACL,
679685
})
680686
if err != nil {
681687
return xerrors.Errorf("update template metadata: %w", err)

codersdk/templates.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ type UpdateTemplateMeta struct {
241241
// If passed an empty string, will remove the deprecated message, making
242242
// the template usable for new workspaces again.
243243
DeprecationMessage *string `json:"deprecation_message"`
244+
// DisableEveryoneGroupAccess allows optionally disabling the default
245+
// behavior of granting the 'everyone' group access to use the template.
246+
// If this is set to true, the template will not be available to all users,
247+
// and must be explicitly granted to users or groups in the permissions settings
248+
// of the template.
249+
DisableEveryoneGroupAccess bool `json:"disable_everyone_group_access"`
244250
}
245251

246252
type TemplateExample struct {

docs/cli/templates_push.md

Lines changed: 58 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)