Documentation
¶
Overview ¶
Package environments defines data structure representing a environment instance and methods for interacting with them it is left to concrete implementations in package db or others to implement these interfaces
Index ¶
- Variables
- func Seed(db *gorm.DB) ([]models.Environment, error)
- type EnvironmentController
- func (environmentController *EnvironmentController) CreateNew(newEnvironment models.CreateEnvironmentRequest) (models.Environment, error)
- func (environmentController EnvironmentController) DoesEnvironmentExist(name string) (id int, ok bool)
- func (environmentController *EnvironmentController) FindOrCreate(name string) (int, error)
- func (environmentController *EnvironmentController) GetByID(ID int) (models.Environment, error)
- func (environmentController *EnvironmentController) GetByName(name string) (models.Environment, error)
- func (environmentController *EnvironmentController) ListAll() ([]models.Environment, error)
- func (ec *EnvironmentController) RegisterHandlers(routerGroup *gin.RouterGroup)
- type EnvironmentResponse
- type EnvironmentSerializer
- type EnvironmentsSerializer
- type MockEnvironmentStore
- func (m *MockEnvironmentStore) CreateNew(newEnvironment models.CreateEnvironmentRequest) (models.Environment, error)
- func (m *MockEnvironmentStore) GetByID(id int) (models.Environment, error)
- func (m *MockEnvironmentStore) GetByName(name string) (models.Environment, error)
- func (m *MockEnvironmentStore) ListAll() ([]models.Environment, error)
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrBadCreateRequest error = errors.New("error invalid create environment request. environment name is required")
ErrBadCreateRequest is an error type used when a create environment request fails validation checks
Functions ¶
Types ¶
type EnvironmentController ¶
type EnvironmentController struct {
// contains filtered or unexported fields
}
EnvironmentController is the management layer for environments
func NewController ¶
func NewController(dbConn *gorm.DB) *EnvironmentController
NewController accepts a gorm DB connection and returns a new instance of the environment controller
func NewMockController ¶ added in v0.0.2
func NewMockController(mockStore *MockEnvironmentStore) *EnvironmentController
NewMockController returns an EnvironmentController instance with the provided mock of the storage layer for use in unit tests
func (*EnvironmentController) CreateNew ¶
func (environmentController *EnvironmentController) CreateNew(newEnvironment models.CreateEnvironmentRequest) (models.Environment, error)
CreateNew is the public api on the environmentController for persisting a new service entity to the data store
func (EnvironmentController) DoesEnvironmentExist ¶
func (environmentController EnvironmentController) DoesEnvironmentExist(name string) (id int, ok bool)
DoesEnvironmentExist is a helper method to check if a environment with the given name already exists in sherlock's data storage
func (*EnvironmentController) FindOrCreate ¶ added in v0.0.7
func (environmentController *EnvironmentController) 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 (*EnvironmentController) GetByID ¶ added in v0.0.13
func (environmentController *EnvironmentController) GetByID(ID int) (models.Environment, error)
GetByName is the public API for looking up a environment from the data store by name
func (*EnvironmentController) GetByName ¶
func (environmentController *EnvironmentController) GetByName(name string) (models.Environment, error)
GetByName is the public API for looking up a environment from the data store by name
func (*EnvironmentController) ListAll ¶
func (environmentController *EnvironmentController) ListAll() ([]models.Environment, error)
ListAll is the public api for listing out all environments tracked by sherlock
func (*EnvironmentController) RegisterHandlers ¶ added in v0.0.2
func (ec *EnvironmentController) RegisterHandlers(routerGroup *gin.RouterGroup)
RegisterHandlers accepts a routergroup and will attach all the handlers for working with environment entities to it
type EnvironmentResponse ¶ added in v0.0.2
EnvironmentResponse is the type that environment entities are serialized to and used in responses to clients
type EnvironmentSerializer ¶ added in v0.0.3
type EnvironmentSerializer struct {
Environment models.Environment
}
func (*EnvironmentSerializer) Response ¶ added in v0.0.3
func (es *EnvironmentSerializer) Response() EnvironmentResponse
type EnvironmentsSerializer ¶ added in v0.0.2
type EnvironmentsSerializer struct {
Environments []models.Environment
}
EnvironmentsSerializer is used to convert a list of environment model types to a Respopnse type used to send environment info to clients
func (*EnvironmentsSerializer) Response ¶ added in v0.0.2
func (es *EnvironmentsSerializer) Response() []EnvironmentResponse
Response is a function that Serializers a slice of Environment models to responses suitable for sending to clients
type MockEnvironmentStore ¶ added in v0.0.2
MockEnvironmentStore is a concrete type that implements environmentStore interface for use in unit tests
func (*MockEnvironmentStore) CreateNew ¶ added in v0.0.18
func (m *MockEnvironmentStore) CreateNew(newEnvironment models.CreateEnvironmentRequest) (models.Environment, error)
func (*MockEnvironmentStore) GetByID ¶ added in v0.0.18
func (m *MockEnvironmentStore) GetByID(id int) (models.Environment, error)
func (*MockEnvironmentStore) GetByName ¶ added in v0.0.18
func (m *MockEnvironmentStore) GetByName(name string) (models.Environment, error)
func (*MockEnvironmentStore) ListAll ¶ added in v0.0.18
func (m *MockEnvironmentStore) ListAll() ([]models.Environment, error)
type Response ¶
type Response struct { Environments []EnvironmentResponse `json:"environments"` Error string `json:"error,omitempty"` }
Response is a type that allows all data returned from the /environment api group to share a consistent structure