Documentation ¶
Index ¶
- Variables
- func NewAllocationPoolStore(dbconn *gorm.DB) allocationPoolStore
- func NewBuildStore(dbConn *gorm.DB) buildStore
- func NewClusterStore(dbconn *gorm.DB) clusterStore
- func NewDeployStore(dbConn *gorm.DB) deployStore
- func NewEnvironmentStore(dbconn *gorm.DB) environmentStore
- func NewServiceInstanceStore(dbConn *gorm.DB) serviceInstanceStore
- func NewServiceStore(db *gorm.DB) serviceStore
- type AllocationPool
- type AllocationPoolStore
- type Build
- type BuildStore
- type Cluster
- type ClusterStore
- type CreateAllocationPoolRequest
- type CreateClusterRequest
- type CreateEnvironmentRequest
- type CreateServiceRequest
- type Deploy
- type DeployStore
- type Environment
- type EnvironmentStore
- type Service
- type ServiceInstance
- type ServiceInstanceStore
- type ServiceStore
Constants ¶
This section is empty.
Variables ¶
var ( ErrBuildNotFound error = gorm.ErrRecordNotFound ErrDuplicateVersionString error = errors.New("field version_string for builds must be unique") // ErrBadCreateRequest is an error type used when a create servie request fails validation checks ErrBadCreateRequest error = errors.New("error invalid create build request") )
ErrBuildNotFound is returned when a specific build look up fails
var ErrAllocationPoolNotFound = gorm.ErrRecordNotFound
ErrAllocationPoolNotFound is the error to represent a failed lookup of a allocationPool db record
var ErrClusterNotFound = gorm.ErrRecordNotFound
ErrClusterNotFound is the error to represent a failed lookup of a cluster db record
var ( // ErrDeployNotFound is retunrned when unable to find a deployment db record that matches a get query ErrDeployNotFound = gorm.ErrRecordNotFound )
var ErrEnvironmentNotFound = gorm.ErrRecordNotFound
ErrEnvironmentNotFound is the error to represent a failed lookup of a environment db record
var ( // ErrServiceInstanceNotFound is a wrapper around gorms failed lookup error specifically // for failure to find a service instance ErrServiceInstanceNotFound = gorm.ErrRecordNotFound )
var (
ErrServiceNotFound = gorm.ErrRecordNotFound
)
ErrServiceNotFound is the error to represent a failed lookup of a service entity
Functions ¶
func NewAllocationPoolStore ¶
NewAllocationPoolStore creates a db connection via gorm
func NewBuildStore ¶
func NewClusterStore ¶
creates a db connection via gorm
func NewDeployStore ¶
func NewEnvironmentStore ¶
func NewServiceInstanceStore ¶
func NewServiceStore ¶
Types ¶
type AllocationPool ¶
type AllocationPool struct { ID int `gorm:"primaryKey;uniqueIndex"` Name string `gorm:"not null;default:null"` CreatedAt time.Time UpdatedAt time.Time Environments []Environment }
AllocationPool is the data structure that models a persisted to a database via gorm
type AllocationPoolStore ¶
type AllocationPoolStore interface { ListAll() ([]AllocationPool, error) CreateNew(CreateAllocationPoolRequest) (AllocationPool, error) GetByID(int) (AllocationPool, error) GetByName(string) (AllocationPool, error) AddEnvironmentByID(AllocationPool, int) (AllocationPool, error) }
allocationPoolStore is the interface defining allowed db actions for AllocationPool
type Build ¶
type Build struct { ID int VersionString string `gorm:"not null;default:null"` CommitSha string BuildURL string BuiltAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time UpdatedAt time.Time ServiceID int Service Service `gorm:"foreignKey:ServiceID;references:ID"` }
Build is the structure used to represent a build entity in sherlock's db persistence layer
type BuildStore ¶
type Cluster ¶
type Cluster struct { ID int `gorm:"primaryKey;uniqueIndex"` Name string `gorm:"not null;default:null"` GoogleProject string CreatedAt time.Time UpdatedAt time.Time }
Cluster is the data structure that models a persisted to a database via gorm
type ClusterStore ¶
type ClusterStore interface { ListAll() ([]Cluster, error) CreateNew(CreateClusterRequest) (Cluster, error) GetByID(int) (Cluster, error) GetByName(string) (Cluster, error) }
clusterStore is the interface defining allowed db actions for Cluster
type CreateAllocationPoolRequest ¶
type CreateAllocationPoolRequest struct { Name string `json:"name" binding:"required"` Environments []Environment }
CreateAllocationPoolRequest struct defines the data required to create a new allocationPool in db
func (CreateAllocationPoolRequest) AllocationPoolReq ¶
func (createAllocationPoolRequest CreateAllocationPoolRequest) AllocationPoolReq() AllocationPool
creates a allocationPool entity object to be persisted with the database from a request to create a allocationPool
type CreateClusterRequest ¶
type CreateClusterRequest struct {
Name string `json:"name" binding:"required"`
}
CreateClusterRequest struct defines the data required to create a new cluster in db
func (CreateClusterRequest) ClusterReq ¶
func (createClusterRequest CreateClusterRequest) ClusterReq() Cluster
creates a cluster entity object to be persisted with the database from a request to create a cluster.
type CreateEnvironmentRequest ¶
type CreateEnvironmentRequest struct {
Name string `json:"name" binding:"required"`
}
CreateEnvironmentRequest struct defines the data required to create a new environment in db
func (CreateEnvironmentRequest) EnvironmentReq ¶
func (createEnvironmentRequest CreateEnvironmentRequest) EnvironmentReq() Environment
creates a environment entity object to be persisted with the database from a request to create a environment
type CreateServiceRequest ¶
type CreateServiceRequest struct { Name string `json:"name" binding:"required"` RepoURL string `json:"repo_url" binding:"required"` }
CreateServiceRequest is a type used to represent the information required to register a new service in sherlock
func (CreateServiceRequest) Service ¶
func (cr CreateServiceRequest) Service() Service
creates a service entity object to be persisted with the database from a request to create a service
type Deploy ¶
type Deploy struct { ID int ServiceInstanceID int ServiceInstance ServiceInstance `gorm:"foreignKey:ServiceInstanceID;references:ID"` BuildID int Build Build `gorm:"foreignKey:BuildID;references:ID"` CreatedAt time.Time UpdatedAt time.Time }
Deploy is the type defining the database model for a deployment. It is an association between a service instance and a build
func (*Deploy) CalculateLeadTimeHours ¶
type DeployStore ¶
type Environment ¶
type Environment struct { ID int `gorm:"primaryKey"` Name string `gorm:"not null;default:null"` IsPermanent bool Requester string DestroyedAt time.Time CreatedAt time.Time UpdatedAt time.Time AllocationPoolID *int `gorm:"default:null"` }
Environment is the data structure that models a persisted to a database via gorm
func SeedEnvironments ¶
func SeedEnvironments(db *gorm.DB) ([]Environment, error)
SeedEnvironments takes a gorm DB connection and will seed a db with some fake environment data for use in functional testing
type EnvironmentStore ¶
type EnvironmentStore interface { ListAll() ([]Environment, error) CreateNew(CreateEnvironmentRequest) (Environment, error) GetByID(int) (Environment, error) GetByName(string) (Environment, error) }
environmentStore is the interface defining allowed db actions for Environment
type Service ¶
type Service struct { ID int `gorm:"primaryKey" faker:"unique"` Name string `gorm:"not null;default:null"` RepoURL string CreatedAt time.Time UpdatedAt time.Time }
Service is the data structure that models a service entity persisted to a database via gorm
type ServiceInstance ¶
type ServiceInstance struct { ID int ServiceID int Service Service `gorm:"foreignKey:ServiceID;references:ID"` EnvironmentID int Environment Environment `gorm:"foreignKey:EnvironmentID;references:ID"` ClusterID int `gorm:"default:null"` Cluster Cluster `gorm:"foreignKey:ClusterID;references:ID"` CreatedAt time.Time UpdatedAt time.Time }
ServiceInstance is the model type for interacting with the database representation of service instances
func SeedServiceInstances ¶
func SeedServiceInstances(db *gorm.DB) ([]ServiceInstance, error)
SeedServiceInstances is used to populate the database with Service Instance entities solely intended for use in testing
type ServiceInstanceStore ¶
type ServiceInstanceStore interface { ListAll() ([]ServiceInstance, error) CreateNew(clusterID, environmentID, serviceID int) (ServiceInstance, error) GetByEnvironmentAndServiceID(environmentID, serviceID int) (ServiceInstance, error) Reload(serviceInstance ServiceInstance, reloadCluster bool, reloadEnvironment bool, reloadService bool) (ServiceInstance, error) }
type ServiceStore ¶
type ServiceStore interface { ListAll() ([]Service, error) CreateNew(CreateServiceRequest) (Service, error) GetByName(string) (Service, error) }
serviceStore is the interface type that defines the methods required for implementing the persistence layer for services entities