From a52ef1a066099bb8df23dcbf6e9258bd283a5ead Mon Sep 17 00:00:00 2001 From: bcmmbaga Date: Tue, 10 Dec 2024 16:49:32 +0100 Subject: [PATCH] Add missing network resource in account copy Signed-off-by: bcmmbaga --- management/server/account.go | 6 ++++++ management/server/networks/network_resource.go | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/management/server/account.go b/management/server/account.go index 8ee9db44a..3729972a7 100644 --- a/management/server/account.go +++ b/management/server/account.go @@ -894,6 +894,11 @@ func (a *Account) Copy() *Account { networkRouters = append(networkRouters, router.Copy()) } + networkResources := []*networks.NetworkResource{} + for _, resource := range a.NetworkResources { + networkResources = append(networkResources, resource.Copy()) + } + return &Account{ Id: a.Id, CreatedBy: a.CreatedBy, @@ -914,6 +919,7 @@ func (a *Account) Copy() *Account { Settings: settings, Networks: nets, NetworkRouters: networkRouters, + NetworkResources: networkResources, } } diff --git a/management/server/networks/network_resource.go b/management/server/networks/network_resource.go index 2a86cb0d7..79e7bee41 100644 --- a/management/server/networks/network_resource.go +++ b/management/server/networks/network_resource.go @@ -49,6 +49,18 @@ func NewNetworkResource(accountID, networkID, name, description, address string) }, nil } +func (n *NetworkResource) Copy() *NetworkResource { + return &NetworkResource{ + ID: n.ID, + AccountID: n.AccountID, + NetworkID: n.NetworkID, + Name: n.Name, + Description: n.Description, + Type: n.Type, + Address: n.Address, + } +} + // getResourceType returns the type of the resource based on the address func getResourceType(address string) (NetworkResourceType, error) { if ip, cidr, err := net.ParseCIDR(address); err == nil {