chore: Return copied templates to prevent reference issues (#6679)

This commit is contained in:
Steven Masley
2023-03-20 13:13:21 -05:00
committed by GitHub
parent cb846bab46
commit 65945aef16
2 changed files with 19 additions and 7 deletions
+9
View File
@@ -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()