-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4f9a0f1
commit b833691
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package models | ||
|
||
import ( | ||
"net" | ||
|
||
"github.com/google/uuid" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// Ipam represents an entry in the Ipam table | ||
type Ipam struct { | ||
gorm.Model | ||
|
||
// ID is a UUID for the APIContract | ||
ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` | ||
|
||
// ProjectID is the ID of the project that the config belongs to. | ||
// This should be a foreign key, but GORM doesnt play well with FKs. | ||
ProjectID int `json:"project_id"` | ||
|
||
CIDR net.IPNet `gorm:"type:cidr;column:cidr_range"` | ||
} | ||
|
||
// TableName overrides the table name | ||
func (Ipam) TableName() string { | ||
return "ipam" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package gorm | ||
|
||
import ( | ||
"github.com/porter-dev/porter/internal/repository" | ||
"gorm.io/gorm" | ||
) | ||
|
||
// Ipam uses gorm.DB for querying the database | ||
type Ipam struct { | ||
db *gorm.DB | ||
} | ||
|
||
// NewIpamRepository creates an IPAM connection | ||
func NewIpamRepository(db *gorm.DB) repository.IpamRepository { | ||
return &Ipam{db} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package repository | ||
|
||
// IpamRepository represents the set of queries on the Ipam model | ||
type IpamRepository interface{} |