Documentation ¶
Overview ¶
Package builds contains the definitions for a control plan for sherlock's build management systems. It also defines api routes for that control plane
Index ¶
- Variables
- type Build
- type BuildController
- func (bc *BuildController) CreateNew(newBuild CreateBuildRequest) (Build, error)
- func (bc *BuildController) GetByID(id int) (Build, error)
- func (bc *BuildController) GetByVersionString(versionString string) (Build, error)
- func (bc *BuildController) ListAll() ([]Build, error)
- func (bc *BuildController) RegisterHandlers(routerGroup *gin.RouterGroup)
- type BuildResponse
- type BuildSerializer
- type BuildsSerializer
- type CreateBuildRequest
- type Response
Constants ¶
This section is empty.
Variables ¶
var ( ErrBuildNotFound error = gorm.ErrRecordNotFound ErrDuplicateVersionString error = errors.New("field version_string for builds must be unique") )
ErrBuildNotFound is returned when a specific build look up fails
var ErrBadCreateRequest error = errors.New("error invalid create build request")
ErrBadCreateRequest is an error type used when a create servie request fails validation checks
var ErrInvalidBuildID error = errors.New("unable to lookup build, received invalid id parameter")
ErrInvalidBuildID is returned when the getByID method receives an id param that can't be converted to int
Functions ¶
This section is empty.
Types ¶
type Build ¶
type Build struct { ID int VersionString string `gorm:"not null;default:null"` CommitSha string BuildURL string BuiltAt time.Time `gorm:"autoCreateTime"` CreatedAt time.Time UpdatedAt time.Time ServiceID int Service services.Service `gorm:"foreignKey:ServiceID;references:ID"` }
Build is the structure used to represent a build entity in sherlock's db persistence layer
type BuildController ¶
type BuildController struct {
// contains filtered or unexported fields
}
BuildController is the management layer that processes requests to the /builds api group
func NewController ¶
func NewController(dbConn *gorm.DB) *BuildController
NewController returns an instance of the controller struct for interacting with build entities. It embeds a buildStore interface for operations on the build persistence layer
func (*BuildController) CreateNew ¶
func (bc *BuildController) CreateNew(newBuild CreateBuildRequest) (Build, error)
CreateNew is the Public API on the build controller for saving a new build entity to persistent storage
func (*BuildController) GetByID ¶
func (bc *BuildController) GetByID(id int) (Build, error)
GetByID is the public api on the build controller for performing a lookup of a build entity by ID
func (*BuildController) GetByVersionString ¶ added in v0.0.8
func (bc *BuildController) GetByVersionString(versionString string) (Build, error)
GetByVersionString will perform a look up of a build entity using it's unique version string ie image repo + tag
func (*BuildController) ListAll ¶
func (bc *BuildController) ListAll() ([]Build, error)
ListAll is the public API on the build controller for listing out all builds
func (*BuildController) RegisterHandlers ¶
func (bc *BuildController) RegisterHandlers(routerGroup *gin.RouterGroup)
RegisterHandlers accepts a gin router group and attaches handlers for working with build entities
type BuildResponse ¶
type BuildResponse struct { ID int `json:"id"` VersionString string `json:"version_string"` CommitSha string `json:"commit_sha"` BuildURL string `json:"build_url,omitempty"` BuiltAt time.Time `json:"built_at,omitempty"` Service services.ServiceResponse `json:"service"` }
BuildResponse is the type used to ensure that response bodies from the /builds api group have a consistent structure
type BuildSerializer ¶
type BuildSerializer struct {
Build Build
}
BuildSerializer takes a Build model entity and translates it into a response
func (*BuildSerializer) Response ¶
func (bs *BuildSerializer) Response() BuildResponse
Response method performs the serialization from a Build entity to Build Response
type BuildsSerializer ¶
type BuildsSerializer struct {
Builds []Build
}
BuildsSerializer is used to transform a slice of builds into the Response type
func (*BuildsSerializer) Response ¶
func (bs *BuildsSerializer) Response() []BuildResponse
Response transforms a list of build model entities into BuildResponse's
type CreateBuildRequest ¶
type CreateBuildRequest struct { VersionString string `json:"version_string" binding:"required"` CommitSha string `json:"commit_sha" binding:"required"` BuildURL string `json:"build_url,omitempty"` BuiltAt time.Time `json:"built_at,omitempty"` ServiceName string `json:"service_name" binding:"required"` ServiceRepo string `json:"service_repo"` }
CreateBuildRequest is the type used to validate a request for a new build
type Response ¶
type Response struct { Builds []BuildResponse `json:"builds"` Error string `json:"error,omitempty"` }
Response is a type that allows all data returned from the /builds api group to share a consistent structure