mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-14 02:41:34 +01:00
[management] Add name attr to network resource (#3011)
This commit is contained in:
parent
623fcb0535
commit
0812cc61b9
@ -23,25 +23,29 @@ func (p NetworkResourceType) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type NetworkResource struct {
|
type NetworkResource struct {
|
||||||
ID string `gorm:"index"`
|
ID string `gorm:"index"`
|
||||||
NetworkID string `gorm:"index"`
|
NetworkID string `gorm:"index"`
|
||||||
AccountID string `gorm:"index"`
|
AccountID string `gorm:"index"`
|
||||||
Type NetworkResourceType
|
Name string
|
||||||
Address 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)
|
resourceType, err := getResourceType(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("invalid address: %w", err)
|
return nil, fmt.Errorf("invalid address: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &NetworkResource{
|
return &NetworkResource{
|
||||||
ID: xid.New().String(),
|
ID: xid.New().String(),
|
||||||
AccountID: accountID,
|
AccountID: accountID,
|
||||||
NetworkID: networkID,
|
NetworkID: networkID,
|
||||||
Type: resourceType,
|
Name: name,
|
||||||
Address: address,
|
Description: description,
|
||||||
|
Type: resourceType,
|
||||||
|
Address: address,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user