builds

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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

View Source
var ErrBadCreateRequest error = errors.New("error invalid create build request")

ErrBadCreateRequest is an error type used when a create servie request fails validation checks

View Source
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
	CommitSha     string
	BuildURL      string
	BuiltAt       time.Time `gorm:"autoCreateTime"`
	CreatedAt     time.Time
	UpdatedAt     time.Time
	ServiceID     int
	Service       services.Service
}

Build is the structure used to represent a build entity in sherlock's db persistence layer

func Seed added in v0.0.2

func Seed(db *gorm.DB) ([]Build, error)

Seed is a testing utility used in integration tests to populate a postgres DB with fake Build entities

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) 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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL