Documentation
¶
Overview ¶
Package services defines the control plane for sherlock's service entities and api routes for interating with those control plane methods
Index ¶
- Variables
- func Seed(db *gorm.DB) ([]models.Service, error)
- type MockServiceStore
- type Response
- type ServiceController
- func (sc *ServiceController) CreateNew(newService models.CreateServiceRequest) (models.Service, error)
- func (sc *ServiceController) DoesServiceExist(name string) (id int, ok bool)
- func (sc *ServiceController) FindOrCreate(name string) (int, error)
- func (sc *ServiceController) GetByName(name string) (models.Service, error)
- func (sc *ServiceController) ListAll() ([]models.Service, error)
- func (sc *ServiceController) RegisterHandlers(routerGroup *gin.RouterGroup)
- type ServiceResponse
- type ServiceSerializer
- type ServicesSerializer
Constants ¶
This section is empty.
Variables ¶
var ErrBadCreateRequest error = errors.New("error invalid create service request. service name and repo url are required")
ErrBadCreateRequest is an error type used when a create servie request fails validation checks
Functions ¶
Types ¶
type MockServiceStore ¶
MockServiceStore is used for mocking underlying database operations for services in unit tests
func (*MockServiceStore) CreateNew ¶ added in v0.0.18
func (m *MockServiceStore) CreateNew(newService models.CreateServiceRequest) (models.Service, error)
type Response ¶
type Response struct { Services []ServiceResponse `json:"services"` Error string `json:"error,omitempty"` }
Response is a type that allows all data returned from the /service api group to share a consistent structure
type ServiceController ¶
type ServiceController struct {
// contains filtered or unexported fields
}
ServiceController is the management layer for CRUD operations for service entities
func NewController ¶
func NewController(dbConn *gorm.DB) *ServiceController
NewController accepts a gorm DB connection and returns a new instance of the service controller
func NewMockController ¶
func NewMockController(mockStore *MockServiceStore) *ServiceController
NewMockController returns a service controller that will use a customizable mock store for use in tests in other packages
func (*ServiceController) CreateNew ¶
func (sc *ServiceController) CreateNew(newService models.CreateServiceRequest) (models.Service, error)
CreateNew is the public api on the serviceController for persisting a new service entity to the data store
func (*ServiceController) DoesServiceExist ¶
func (sc *ServiceController) DoesServiceExist(name string) (id int, ok bool)
DoesServiceExist is a helper method to check if a service with the given name already exists in sherlock's data storage
func (*ServiceController) FindOrCreate ¶ added in v0.0.7
func (sc *ServiceController) FindOrCreate(name string) (int, error)
FindOrCreate will attempt to look an environment by name and return its ID if successful if unsuccessful it will create a new environment from the provider name and return that id
func (*ServiceController) GetByName ¶
func (sc *ServiceController) GetByName(name string) (models.Service, error)
GetByName is the public API for looking up a service from the data store by name
func (*ServiceController) ListAll ¶
func (sc *ServiceController) ListAll() ([]models.Service, error)
ListAll is the public api for listing out all services tracked by sherlock
func (*ServiceController) RegisterHandlers ¶
func (sc *ServiceController) RegisterHandlers(routerGroup *gin.RouterGroup)
RegisterHandlers accepts a gin router and will attach handlers for working with Service entities to it
type ServiceResponse ¶
type ServiceResponse struct { ID int `json:"id"` Name string `json:"name"` RepoURL string `json:"repo_url"` }
ServiceResponse is the type used to serialize Service data that is returned to clients of the sherlock api
type ServiceSerializer ¶
ServiceSerializer is used to serializer a single Service model to a used to generate responses from the /services api group
func (*ServiceSerializer) Response ¶
func (ss *ServiceSerializer) Response() ServiceResponse
Response takes a Service Model entity and transforms it into a ServiceResponse
type ServicesSerializer ¶
ServicesSerializer is used to serialize a ServiceModel entity to a a format used in http response bodies
func (*ServicesSerializer) Response ¶
func (ss *ServicesSerializer) Response() []ServiceResponse
Response serializes Service models into Service Responses