Merge branch 'feature/new-networks-concept' into add-networks-db-support

This commit is contained in:
bcmmbaga 2024-12-10 10:59:28 +01:00
commit 21eca7e1d1
No known key found for this signature in database
GPG Key ID: 511EED5C928AD547

View File

@ -23,25 +23,29 @@ func (p NetworkResourceType) String() string {
}
type NetworkResource struct {
ID string `gorm:"index"`
NetworkID string `gorm:"index"`
AccountID string `gorm:"index"`
Type NetworkResourceType
Address string
ID string `gorm:"index"`
NetworkID string `gorm:"index"`
AccountID string `gorm:"index"`
Name string
Description string
Type NetworkResourceType
Address string
}
func NewNetworkResource(accountID, networkID, address string) (*NetworkResource, error) {
func NewNetworkResource(accountID, networkID, name, description, address string) (*NetworkResource, error) {
resourceType, err := getResourceType(address)
if err != nil {
return nil, fmt.Errorf("invalid address: %w", err)
}
return &NetworkResource{
ID: xid.New().String(),
AccountID: accountID,
NetworkID: networkID,
Type: resourceType,
Address: address,
ID: xid.New().String(),
AccountID: accountID,
NetworkID: networkID,
Name: name,
Description: description,
Type: resourceType,
Address: address,
}, nil
}