models

package
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2022 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

View Source
var ErrAllocationPoolNotFound = gorm.ErrRecordNotFound

ErrAllocationPoolNotFound is the error to represent a failed lookup of a allocationPool db record

View Source
var ErrClusterNotFound = gorm.ErrRecordNotFound

ErrClusterNotFound is the error to represent a failed lookup of a cluster db record

View Source
var (
	// ErrDeployNotFound is retunrned when unable to find a deployment db record that matches a get query
	ErrDeployNotFound = gorm.ErrRecordNotFound
)
View Source
var ErrEnvironmentNotFound = gorm.ErrRecordNotFound

ErrEnvironmentNotFound is the error to represent a failed lookup of a environment db record

View Source
var (
	// ErrServiceInstanceNotFound is a wrapper around gorms failed lookup error specifically
	// for failure to find a service instance
	ErrServiceInstanceNotFound = gorm.ErrRecordNotFound
)
View Source
var (
	ErrServiceNotFound = gorm.ErrRecordNotFound
)

ErrServiceNotFound is the error to represent a failed lookup of a service entity

Functions

func NewAllocationPoolStore added in v0.0.18

func NewAllocationPoolStore(dbconn *gorm.DB) allocationPoolStore

NewAllocationPoolStore creates a db connection via gorm

func NewBuildStore added in v0.0.18

func NewBuildStore(dbConn *gorm.DB) buildStore

func NewClusterStore

func NewClusterStore(dbconn *gorm.DB) clusterStore

creates a db connection via gorm

func NewDeployStore added in v0.0.18

func NewDeployStore(dbConn *gorm.DB) deployStore

func NewEnvironmentStore added in v0.0.18

func NewEnvironmentStore(dbconn *gorm.DB) environmentStore

func NewServiceInstanceStore added in v0.0.18

func NewServiceInstanceStore(dbConn *gorm.DB) serviceInstanceStore

func NewServiceStore added in v0.0.18

func NewServiceStore(db *gorm.DB) serviceStore

Types

type AllocationPool added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

type BuildStore interface {
	ListAll() ([]Build, error)
	CreateNew(Build) (Build, error)
	GetByID(int) (Build, error)
	GetByVersionString(string) (Build, error)
}

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

func (deploy *Deploy) CalculateLeadTimeHours() float64

type DeployStore added in v0.0.18

type DeployStore interface {
	CreateDeploy(buildID, serviceInstanceID int) (Deploy, error)
	GetDeploysByServiceInstance(serviceInstanceID int) ([]Deploy, error)
	GetMostRecentDeployByServiceInstance(serviceInstanceID int) (Deploy, error)
}

type Environment added in v0.0.18

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

type EnvironmentStore added in v0.0.18

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 added in v0.0.18

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 added in v0.0.18

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

type ServiceInstanceStore added in v0.0.18

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 added in v0.0.18

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL