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
- type CreateEnvironmentRequest
- type Environment
- type EnvironmentController
- func (environmentController *EnvironmentController) CreateNew(newEnvironment CreateEnvironmentRequest) (Environment, error)
- func (environmentController EnvironmentController) DoesEnvironmentExist(name string) (id int, ok bool)
- func (environmentController *EnvironmentController) GetByName(name string) (Environment, error)
- func (environmentController *EnvironmentController) ListAll() ([]Environment, error)
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrEnvironmentNotFound = gorm.ErrRecordNotFound
ErrEnvironmentNotFound is the error to represent a failed lookup of a environment db record
Functions ¶
This section is empty.
Types ¶
type CreateEnvironmentRequest ¶
type CreateEnvironmentRequest struct {
Name string `json:"name" binding:"required"`
}
CreateEnvironmentRequest struct defines the data required to create a new environment in db
type Environment ¶
type Environment struct { ID int Name string IsPermanent bool Requester string DestroyedAt time.Time CreatedAt time.Time UpdatedAt time.Time }
Environment is the data structure that models a persisted to a database via gorm
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 (*EnvironmentController) CreateNew ¶
func (environmentController *EnvironmentController) CreateNew(newEnvironment CreateEnvironmentRequest) (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) GetByName ¶
func (environmentController *EnvironmentController) GetByName(name string) (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() ([]Environment, error)
ListAll is the public api for listing out all environments tracked by sherlock
type Response ¶
type Response struct { Environments []Environment `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