mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: Return copied templates to prevent reference issues (#6679)
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/coder/coder/coderd/rbac"
|
||||
)
|
||||
|
||||
@@ -86,6 +88,13 @@ func (t Template) RBACObject() rbac.Object {
|
||||
WithGroupACL(t.GroupACL)
|
||||
}
|
||||
|
||||
func (t Template) DeepCopy() Template {
|
||||
cpy := t
|
||||
cpy.UserACL = maps.Clone(t.UserACL)
|
||||
cpy.GroupACL = maps.Clone(t.GroupACL)
|
||||
return cpy
|
||||
}
|
||||
|
||||
func (TemplateVersion) RBACObject(template Template) rbac.Object {
|
||||
// Just use the parent template resource for controlling versions
|
||||
return template.RBACObject()
|
||||
|
||||
Reference in New Issue
Block a user