deploys

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2021 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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 (
	// 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 CreateServiceInstanceRequest added in v0.0.7

type CreateServiceInstanceRequest struct {
	EnvironmentName string
	ServiceName     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

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"`
	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) 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

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

Response Will generate a slice of Service Instance Response from ServiceInstancesSerializer

Jump to

Keyboard shortcuts

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