deploys

package
v0.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

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