Documentation
¶
Index ¶
- Variables
- type CreateServiceInstanceRequest
- type ServiceInstance
- type ServiceInstanceController
- func (sic *ServiceInstanceController) CreateNew(newServiceInstance CreateServiceInstanceRequest) (ServiceInstance, error)
- func (sic *ServiceInstanceController) GetByEnvironmentAndServiceName(environmentName, serviceName string) (ServiceInstance, error)
- func (sic *ServiceInstanceController) ListAll() ([]ServiceInstance, error)
- func (sic *ServiceInstanceController) Serialize(serviceInstances ...ServiceInstance) []ServiceInstanceResponse
- type ServiceInstanceResponse
- type ServiceInstanceSerializer
- type ServiceInstancesSerializer
Constants ¶
This section is empty.
Variables ¶
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
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 ¶
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