Add missing network resource in account copy

Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
bcmmbaga 2024-12-10 16:49:32 +01:00
parent 382dba4a85
commit a52ef1a066
No known key found for this signature in database
GPG Key ID: 511EED5C928AD547
2 changed files with 18 additions and 0 deletions

View File

@ -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,
}
}

View File

@ -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 {