Skip to content

Commit

Permalink
Merge pull request #3176 from gravitl/NET-1737
Browse files Browse the repository at this point in the history
NET-1737: use cloned copy of acl object
  • Loading branch information
abhishek9686 authored Nov 4, 2024
2 parents 7dcc866 + 38cb4d8 commit 4f17214
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions logic/acls/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package acls

import (
"encoding/json"
"maps"
"sync"

"github.com/gravitl/netmaker/database"
Expand Down Expand Up @@ -133,7 +134,7 @@ func fetchACLContainer(containerID ContainerID) (ACLContainer, error) {
defer AclMutex.RUnlock()
if servercfg.CacheEnabled() {
if aclContainer, ok := fetchAclContainerFromCache(containerID); ok {
return aclContainer, nil
return maps.Clone(aclContainer), nil
}
}
aclJson, err := fetchACLContainerJson(ContainerID(containerID))
Expand All @@ -147,7 +148,7 @@ func fetchACLContainer(containerID ContainerID) (ACLContainer, error) {
if servercfg.CacheEnabled() {
storeAclContainerInCache(containerID, currentNetworkACL)
}
return currentNetworkACL, nil
return maps.Clone(currentNetworkACL), nil
}

// fetchACLContainerJson - fetch the current ACL of given container except in json string
Expand Down
3 changes: 2 additions & 1 deletion logic/acls/nodeacls/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package nodeacls
import (
"encoding/json"
"fmt"
"maps"
"sync"

"github.com/gravitl/netmaker/logic/acls"
Expand Down Expand Up @@ -67,5 +68,5 @@ func FetchAllACLs(networkID NetworkID) (acls.ACLContainer, error) {
if err != nil {
return nil, err
}
return currentNetworkACL, nil
return maps.Clone(currentNetworkACL), nil
}

0 comments on commit 4f17214

Please sign in to comment.