Documentation ¶
Index ¶
- Variables
- type CreateDeployRequest
- type CreateDeployRequestBody
- type CreateServiceInstanceRequest
- type Deploy
- type DeployController
- func (dc *DeployController) CreateNew(newDeployRequest CreateDeployRequest) (Deploy, error)
- func (dc *DeployController) GetDeploysByEnvironmentAndService(environmentName, serviceName string) ([]Deploy, error)
- func (dc *DeployController) RegisterHandlers(routerGroup *gin.RouterGroup)
- func (dc *DeployController) Serialize(deploy ...Deploy) []DeployResponse
- type DeployResponse
- type DeploysSerializer
- type Response
- type ServiceInstance
- type ServiceInstanceController
- func (sic *ServiceInstanceController) CreateNew(newServiceInstance CreateServiceInstanceRequest) (ServiceInstance, error)
- func (sic *ServiceInstanceController) FindOrCreate(environmentName, serviceName string) (int, error)
- func (sic *ServiceInstanceController) GetByEnvironmentAndServiceName(environmentName, serviceName string) (ServiceInstance, error)
- func (sic *ServiceInstanceController) ListAll() ([]ServiceInstance, error)
- func (sic *ServiceInstanceController) Reload(serviceInstance ServiceInstance, reloadCluster bool, reloadEnvironment bool, ...) (ServiceInstance, error)
- func (sic *ServiceInstanceController) Serialize(serviceInstances ...ServiceInstance) []ServiceInstanceResponse
- type ServiceInstanceResponse
- type ServiceInstanceSerializer
- type ServiceInstancesSerializer
Constants ¶
This section is empty.
Variables ¶
var ErrBadCreateRequest error = errors.New("error invalid create deploy request")
ErrBadCreateRequest is an error type used when a create servie request fails validation checks
var ( // ErrServiceInstanceNotFound is a wrapper around gorms failed lookup error specifically // for failure to find a service instance ErrServiceInstanceNotFound = gorm.ErrRecordNotFound )
var ( // ErrServiceMismatch is an error returned when creating a deploy where the build and service instance // reference different service entities. ErrServiceMismatch = errors.New("service referenced by build and service instance do not match") )
Functions ¶
This section is empty.
Types ¶
type CreateDeployRequest ¶ added in v0.0.8
type CreateDeployRequest struct { EnvironmentName string ServiceName string BuildVersionString string }
CreateDeployRequest is a struct used to contain all the information that is necessary to provision a new deploy
type CreateDeployRequestBody ¶ added in v0.0.9
type CreateDeployRequestBody struct {
VersionString string `json:"version_string" binding:"required"`
}
CreateDeployRequestBody is used to extract any additional data needed to create a new deploy from the request body. currently this is just the version string as the environment and service are determined from path params
type CreateServiceInstanceRequest ¶ added in v0.0.7
type CreateServiceInstanceRequest struct { EnvironmentName string ServiceName string ClusterName string }
CreateServiceInstanceRequest is a type containing the name of an environment and service that sherlock uses to create a new association between the two.
type Deploy ¶ added in v0.0.8
type Deploy struct { ID int ServiceInstanceID int ServiceInstance ServiceInstance `gorm:"foreignKey:ServiceInstanceID;references:ID"` BuildID int Build builds.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
type DeployController ¶ added in v0.0.8
type DeployController struct {
// contains filtered or unexported fields
}
DeployController is a type used to contain all the top level functionality for managing Deploy entities.
func NewDeployController ¶ added in v0.0.8
func NewDeployController(dbConn *gorm.DB) *DeployController
NewDeployController accepts a gorm db connection and returns a controller struct used for the management of deploy entities
func (*DeployController) CreateNew ¶ added in v0.0.8
func (dc *DeployController) CreateNew(newDeployRequest CreateDeployRequest) (Deploy, error)
CreateNew is used to create a new deploy based on a service name, environment name and build version string
func (*DeployController) GetDeploysByEnvironmentAndService ¶ added in v0.0.8
func (dc *DeployController) GetDeploysByEnvironmentAndService(environmentName, serviceName string) ([]Deploy, error)
GetDeploysByEnvironmentAndService will retrieve the deploy history for a given service instance with the associated names
func (*DeployController) RegisterHandlers ¶ added in v0.0.9
func (dc *DeployController) RegisterHandlers(routerGroup *gin.RouterGroup)
RegisterHandlers accepts a gin router group and attaches handlers for working with deploy entities
func (*DeployController) Serialize ¶ added in v0.0.9
func (dc *DeployController) Serialize(deploy ...Deploy) []DeployResponse
Serialize takes a variable number of deploy entities and serializes them into types suitable for use in client responses
type DeployResponse ¶ added in v0.0.9
type DeployResponse struct { ID int `json:"id"` ServiceInstance ServiceInstanceResponse `json:"service_instance"` Build builds.BuildResponse `json:"build"` CreatedAt time.Time `json:"deployed_at"` }
DeployResponse is the type used for generating api responses containing information about deploy(s)
type DeploysSerializer ¶ added in v0.0.9
type DeploysSerializer struct {
// contains filtered or unexported fields
}
DeploysSerializer is used to transform a slice of Deploy models into into deploy responses and can supply additional data to attach to the response
func (*DeploysSerializer) Response ¶ added in v0.0.9
func (ds *DeploysSerializer) Response() []DeployResponse
Response is used to seralize a slice of deploy database models into a slice of deploy api responses
type Response ¶ added in v0.0.9
type Response struct { Deploys []DeployResponse `json:"deploys"` Error string `json:"error,omitempty"` }
Response is a type that allows all data returned from the /builds api group to share a consistent structure
type ServiceInstance ¶
type ServiceInstance struct { ID int ServiceID int Service services.Service `gorm:"foreignKey:ServiceID;references:ID"` EnvironmentID int Environment environments.Environment `gorm:"foreignKey:EnvironmentID;references:ID"` ClusterID int `gorm:"default:null"` Cluster models.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 ServiceInstanceController ¶
type ServiceInstanceController struct {
// contains filtered or unexported fields
}
ServiceInstanceController is the type used to manage logic related to working with ServiceInstance entities
func NewMockController ¶
func NewMockController(mockStore *mockServiceInstanceStore) *ServiceInstanceController
NewMockController returns an EnvironmentController instance with the provided mock of the storage layer for use in unit tests
func NewServiceInstanceController ¶
func NewServiceInstanceController(dbConn *gorm.DB) *ServiceInstanceController
NewServiceInstanceController expects a gorm.DB connection and will provision a new controller instance
func (*ServiceInstanceController) CreateNew ¶ added in v0.0.7
func (sic *ServiceInstanceController) CreateNew(newServiceInstance CreateServiceInstanceRequest) (ServiceInstance, error)
CreateNew accepts the name of an environment and a service. It will perform find or create operations for both and their create an association between them
func (*ServiceInstanceController) FindOrCreate ¶ added in v0.0.8
func (sic *ServiceInstanceController) FindOrCreate(environmentName, serviceName string) (int, error)
FindOrCreate will check if a service instance with the given name and environment already exists if so it returns the id. If not it will create it and then return the id
func (*ServiceInstanceController) GetByEnvironmentAndServiceName ¶ added in v0.0.7
func (sic *ServiceInstanceController) GetByEnvironmentAndServiceName(environmentName, serviceName string) (ServiceInstance, error)
GetByEnvironmentAndServiceName accepts environment and service names as strings and will return the Service_Instance entity representing the association between them if it exists
func (*ServiceInstanceController) ListAll ¶
func (sic *ServiceInstanceController) ListAll() ([]ServiceInstance, error)
ListAll retrieves all service_instance entities from the backing data store
func (*ServiceInstanceController) Reload ¶ added in v0.0.13
func (sic *ServiceInstanceController) Reload(serviceInstance ServiceInstance, reloadCluster bool, reloadEnvironment bool, reloadService bool) (ServiceInstance, error)
Reload reloads a serviceInstance from the DB, optionally loading related Cluster/Environment/Service objects along with it.
func (*ServiceInstanceController) Serialize ¶
func (sic *ServiceInstanceController) Serialize(serviceInstances ...ServiceInstance) []ServiceInstanceResponse
Serialize takes a variable number of service instance entities and serializes them into types suitable for use in client responses
type ServiceInstanceResponse ¶
type ServiceInstanceResponse struct { ID int `json:"id"` Service services.ServiceResponse `json:"service"` Environment environments.EnvironmentResponse `json:"environment"` }
ServiceInstanceResponse is the type that is used to represent data about a ServiceInstance entity in response to clients. Its purpose is to decouple responses from the database model
type ServiceInstanceSerializer ¶
type ServiceInstanceSerializer struct {
// contains filtered or unexported fields
}
ServiceInstanceSerializer is an intermediate type used to convert a Service instance into its response type
func (*ServiceInstanceSerializer) Response ¶
func (sis *ServiceInstanceSerializer) Response() ServiceInstanceResponse
Response consumes a ServiceInstanceSerializer and generated a response type
type ServiceInstancesSerializer ¶
type ServiceInstancesSerializer struct {
ServiceInstances []ServiceInstance
}
ServiceInstancesSerializer is a wrapper around ServiceInstanceSerializer that supports serialization of mulitple ServiceInstance entities
func (*ServiceInstancesSerializer) Response ¶
func (sis *ServiceInstancesSerializer) Response() []ServiceInstanceResponse
Response Will generate a slice of Service Instance Response from ServiceInstancesSerializer