Documentation ¶
Overview ¶
Package build provides database implementations for the Build entity and its related entities.
Index ¶
- Variables
- func ArtifactModel(aa []*Artifact) func(int) database.Model
- func DriverModel(dd []*Driver) func(int) database.Model
- func InitEvent(dis event.Dispatcher) queue.InitFunc
- func InitTagEvent(dis event.Dispatcher) queue.InitFunc
- func JobModel(jj []*Job) func(int) database.Model
- func KeyModel(kk []*Key) func(int) database.Model
- func LoadJobRelations(loaders *database.Loaders, jj ...*Job) error
- func LoadRelations(loaders *database.Loaders, bb ...*Build) error
- func Model(bb []*Build) func(int) database.Model
- func NewTriggerData() triggerData
- func ObjectModel(oo []*Object) func(int) database.Model
- func SelectObject(col string, opts ...query.Option) query.Query
- func StageModel(ss []*Stage) func(int) database.Model
- func TagModel(tt []*Tag) func(int) database.Model
- func TriggerModel(tt []*Trigger) func(int) database.Model
- func VariableModel(vv []*Variable) func(int) database.Model
- func WhereSearch(search string) query.Option
- func WhereStatus(status string) query.Option
- func WhereTag(tag string) query.Option
- type Artifact
- func (a *Artifact) Bind(mm ...database.Model)
- func (a *Artifact) Endpoint(uris ...string) string
- func (a *Artifact) IsZero() bool
- func (a *Artifact) JSON(addr string) map[string]interface{}
- func (a *Artifact) Primary() (string, int64)
- func (a *Artifact) SetPrimary(id int64)
- func (a *Artifact) Values() map[string]interface{}
- type ArtifactStore
- func (s *ArtifactStore) All(opts ...query.Option) ([]*Artifact, error)
- func (s *ArtifactStore) Bind(mm ...database.Model)
- func (s *ArtifactStore) Collect(name string, r io.Reader) (int64, error)
- func (s *ArtifactStore) Create(hash, src, dst string) (*Artifact, error)
- func (s *ArtifactStore) Deleted(ids ...int64) error
- func (s *ArtifactStore) Get(opts ...query.Option) (*Artifact, error)
- func (s *ArtifactStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *ArtifactStore) New() *Artifact
- type Build
- func (b *Build) Bind(mm ...database.Model)
- func (b *Build) Endpoint(uri ...string) string
- func (b *Build) IsZero() bool
- func (b *Build) JSON(addr string) map[string]interface{}
- func (b *Build) Kill(client *redis.Client) error
- func (b *Build) Primary() (string, int64)
- func (b *Build) SetPrimary(id int64)
- func (b *Build) Values() map[string]interface{}
- type Curator
- type Driver
- func (d *Driver) Bind(mm ...database.Model)
- func (*Driver) Endpoint(_ ...string) string
- func (d *Driver) IsZero() bool
- func (*Driver) JSON(_ string) map[string]interface{}
- func (d *Driver) Primary() (string, int64)
- func (d *Driver) SetPrimary(id int64)
- func (d *Driver) Values() map[string]interface{}
- type DriverStore
- func (s *DriverStore) All(opts ...query.Option) ([]*Driver, error)
- func (s *DriverStore) Bind(mm ...database.Model)
- func (s *DriverStore) Create(cfg map[string]string) (*Driver, error)
- func (s *DriverStore) Get(opts ...query.Option) (*Driver, error)
- func (s *DriverStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *DriverStore) New() *Driver
- type Event
- type Form
- type Job
- func (j *Job) Bind(mm ...database.Model)
- func (j *Job) Endpoint(uri ...string) string
- func (j *Job) IsZero() bool
- func (j *Job) JSON(addr string) map[string]interface{}
- func (j *Job) Job(w io.Writer) *runner.Job
- func (j *Job) Primary() (string, int64)
- func (j *Job) SetPrimary(id int64)
- func (j *Job) Values() map[string]interface{}
- type JobStore
- func (s *JobStore) All(opts ...query.Option) ([]*Job, error)
- func (s *JobStore) Bind(mm ...database.Model)
- func (s *JobStore) Create(name, commands string) (*Job, error)
- func (s *JobStore) Finished(id int64, output string, status runner.Status) error
- func (s *JobStore) Get(opts ...query.Option) (*Job, error)
- func (s *JobStore) Index(vals url.Values, opts ...query.Option) ([]*Job, error)
- func (s *JobStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *JobStore) New() *Job
- func (s *JobStore) Started(id int64) error
- type Key
- type KeyStore
- func (s *KeyStore) All(opts ...query.Option) ([]*Key, error)
- func (s *KeyStore) Bind(mm ...database.Model)
- func (s *KeyStore) Copy(kk ...*key.Key) ([]*Key, error)
- func (s *KeyStore) Get(opts ...query.Option) (*Key, error)
- func (s *KeyStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *KeyStore) New() *Key
- type Object
- func (o *Object) Bind(mm ...database.Model)
- func (o *Object) Endpoint(_ ...string) string
- func (o *Object) IsZero() bool
- func (o *Object) JSON(addr string) map[string]interface{}
- func (o *Object) Primary() (string, int64)
- func (o *Object) SetPrimary(id int64)
- func (o *Object) Values() map[string]interface{}
- type ObjectStore
- func (s *ObjectStore) All(opts ...query.Option) ([]*Object, error)
- func (s *ObjectStore) Bind(mm ...database.Model)
- func (s *ObjectStore) Create(objectId int64, name, dst string) (*Object, error)
- func (s *ObjectStore) Get(opts ...query.Option) (*Object, error)
- func (s *ObjectStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *ObjectStore) New() *Object
- func (s *ObjectStore) Place(name string, w io.Writer) (int64, error)
- func (s *ObjectStore) Stat(name string) (os.FileInfo, error)
- type Payload
- type Stage
- func (s *Stage) Bind(mm ...database.Model)
- func (s *Stage) Endpoint(_ ...string) string
- func (s *Stage) IsZero() bool
- func (s *Stage) JSON(addr string) map[string]interface{}
- func (s Stage) Primary() (string, int64)
- func (s *Stage) SetPrimary(id int64)
- func (s Stage) Stage() *runner.Stage
- func (s *Stage) Values() map[string]interface{}
- type StageStore
- func (s StageStore) All(opts ...query.Option) ([]*Stage, error)
- func (s *StageStore) Bind(mm ...database.Model)
- func (s *StageStore) Create(name string, canFail bool) (*Stage, error)
- func (s StageStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s StageStore) New() *Stage
- type Store
- func (s *Store) All(opts ...query.Option) ([]*Build, error)
- func (s *Store) Bind(mm ...database.Model)
- func (s *Store) Create(m manifest.Manifest, t *Trigger, tags ...string) (*Build, error)
- func (s *Store) Finished(id int64, output string, status runner.Status) error
- func (s *Store) Get(opts ...query.Option) (*Build, error)
- func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Build, database.Paginator, error)
- func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *Store) New() *Build
- func (s *Store) Orphan(b *Build) error
- func (s *Store) Paginate(page int64, opts ...query.Option) (database.Paginator, error)
- func (s *Store) Started(id int64) error
- func (s *Store) Submit(ctx context.Context, prd *curlyq.Producer, host string, b *Build) error
- type Tag
- type TagEvent
- type TagForm
- type TagStore
- func (s TagStore) All(opts ...query.Option) ([]*Tag, error)
- func (s *TagStore) Bind(mm ...database.Model)
- func (s *TagStore) Create(userId int64, names ...string) ([]*Tag, error)
- func (s *TagStore) Delete(buildId int64, name string) error
- func (s TagStore) Get(opts ...query.Option) (*Tag, error)
- func (s TagStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s TagStore) New() *Tag
- type Trigger
- func (t *Trigger) Bind(mm ...database.Model)
- func (t Trigger) CommentBody() string
- func (t Trigger) CommentTitle() string
- func (*Trigger) Endpoint(_ ...string) string
- func (t *Trigger) IsZero() bool
- func (t *Trigger) JSON(_ string) map[string]interface{}
- func (t Trigger) Primary() (string, int64)
- func (t *Trigger) SetPrimary(i int64)
- func (t Trigger) String() string
- func (t Trigger) Values() map[string]interface{}
- type TriggerStore
- func (s TriggerStore) All(opts ...query.Option) ([]*Trigger, error)
- func (s *TriggerStore) Bind(mm ...database.Model)
- func (s *TriggerStore) Create(tt ...*Trigger) error
- func (s TriggerStore) Get(opts ...query.Option) (*Trigger, error)
- func (s TriggerStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- type TriggerType
- type Variable
- func (v *Variable) Bind(mm ...database.Model)
- func (v *Variable) Endpoint(_ ...string) string
- func (v *Variable) IsZero() bool
- func (v *Variable) JSON(addr string) map[string]interface{}
- func (v Variable) Primary() (string, int64)
- func (v *Variable) SetPrimary(id int64)
- func (v Variable) Values() map[string]interface{}
- type VariableStore
- func (s VariableStore) All(opts ...query.Option) ([]*Variable, error)
- func (s *VariableStore) Bind(mm ...database.Model)
- func (s *VariableStore) Copy(vv ...*variable.Variable) ([]*Variable, error)
- func (s *VariableStore) Create(key, val string) (*Variable, error)
- func (s VariableStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s VariableStore) New() *Variable
Constants ¶
This section is empty.
Variables ¶
var ( ErrDriver = errors.New("unknown driver") ErrDriverDisabled = errors.New("driver disabled") )
Functions ¶
func ArtifactModel ¶
ArtifactModel is called along with database.ModelSlice to convert the given slice of Artifact models to a slice of database.Model interfaces.
func DriverModel ¶
DriverModel is called along with database.ModelSlice to convert the given slice of Driver models to a slice of database.Model interfaces.
func InitTagEvent ¶ added in v1.1.0
func InitTagEvent(dis event.Dispatcher) queue.InitFunc
func JobModel ¶
JobModel is called along with database.ModelSlice to convert the given slice of Job models to a slice of database.Model interfaces.
func KeyModel ¶
KeyModel is called along with database.ModelSlice to convert the given slice of Key models to a slice of database.Model interfaces.
func LoadJobRelations ¶
LoadRelations loads all of the available relations for the given Job models using the given loaders available.
func LoadRelations ¶
LoadRelations loads all of the available relations for the given Build models using the given loaders available.
func Model ¶
Model is called along with database.ModelSlice to convert the given slice of Build models to a slice of database.Model interfaces.
func NewTriggerData ¶
func NewTriggerData() triggerData
NewTriggerData returns an empty set of data for a build trigger.
func ObjectModel ¶
ObjectModel is called along with database.ModelSlice to convert the given slice of Object models to a slice of database.Model interfaces.
func SelectObject ¶
SelectObject returns SELECT query that will select the given column from the build_objects table with the given query options applied.
func StageModel ¶
StageModel is called along with database.ModelSlice to convert the given slice of Stage models to a slice of database.Model interfaces.
func TagModel ¶
TagModel is called along with database.ModelSlice to convert the given slice of Tag models to a slice of database.Model interfaces.
func TriggerModel ¶
TriggerModel is called along with database.ModelSlice to convert the given slice of Trigger models to a slice of database.Model interfaces.
func VariableModel ¶
VariableModel is called along with database.ModelSlice to convert the given slice of Variable models to a slice of database.Model interfaces.
func WhereSearch ¶
WhereSearch returns a query option that applies a WHERE IN clause to a query. The returned WHERE IN clause operates on the values returned from a SELECT query that uses the given search string.
func WhereStatus ¶
WhereStatus returns a query option that applies a WHERE IN clause to a query using the given status. If the given status is "passed", then it will be expanded to include "passed_with_failures".
Types ¶
type Artifact ¶
type Artifact struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` BuildID int64 `db:"build_id"` JobID int64 `db:"job_id"` Hash string `db:"hash"` Source string `db:"source"` Name string `db:"name"` Size sql.NullInt64 `db:"size"` MD5 []byte `db:"md5"` SHA256 []byte `db:"sha256"` CreatedAt time.Time `db:"created_at"` DeletedAt sql.NullTime `db:"deleted_at"` Build *Build `db:"-"` Job *Job `db:"-"` User *user.User `db:"-"` }
Artifact is the type that represents a file that has been collected from a build environment for a given build. This contains metadata about the file that was collected.
func (*Artifact) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or Job models.
func (*Artifact) Endpoint ¶
Endpoint implements the database.Model interface. If the current Artifact has a nil or zero value Build bound model then an empty string is returned, otherwise the fulld Build endpoint is returned, suffixed with the Artifact endpoint, for example,
/b/l.belardo/10/artifacts/os-release
func (*Artifact) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Artifacts values under each key. If any of the Build, or Job bound models exist on the Artifact, then the JSON representation of these models will be in the returned map, under the build, and job keys respectively.
func (*Artifact) SetPrimary ¶
SetPrimary implements the database.Model interface.
type ArtifactStore ¶
type ArtifactStore struct { database.Store // Build is the bound Build model. If not nil this will bind the Build // model to any Artifact models that are created. If not nil this will // append a WHERE clause on the build_id column for all SELECT queries // performed. Build *Build // Job is the bound Job model. If not nil this will bind the Job model to // any Artifact models that are created. If not nil this will append a // WHERE clause on the job_id column for all SELECT queries performed. Job *Job User *user.User // contains filtered or unexported fields }
ArtifactStore is the type for creating and modifying Artifact models in the database. The ArtifactStore type can have an underlying runner.Collector implementation that can allow for it to be used for collecting artifacts from a build environment.
func NewArtifactStore ¶
func NewArtifactStore(db *sqlx.DB, mm ...database.Model) *ArtifactStore
NewArtifactStore returns a new ArtifactStore for querying the build_artifacts table. Each model passed to this function will be bound to the returned ArtifactStore.
func NewArtifactStoreWithCollector ¶
func NewArtifactStoreWithCollector(db *sqlx.DB, c runner.Collector, mm ...database.Model) *ArtifactStore
NewArtifactStoreWithCollector returns a new ArtifactStore with the given runner.Collector. This allows for the ArtifactStore to be used as a runner.Collector during a build run. Each collected artifact will be updated in the database, with the actual collection being deferred to the given runner.Collector.
func (*ArtifactStore) All ¶
func (s *ArtifactStore) All(opts ...query.Option) ([]*Artifact, error)
All returns a slice of Artifact models, applying each query.Option that is given.
func (*ArtifactStore) Bind ¶
func (s *ArtifactStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either Build or Job models.
func (*ArtifactStore) Collect ¶
Collect looks up the Artifact by the given name, and updates it with the size, md5, and sha256 once the underlying runner.Collector has been successfully invoked. If no underlying collector has been set for the ArtifactStore then it immediately errors.
func (*ArtifactStore) Create ¶
func (s *ArtifactStore) Create(hash, src, dst string) (*Artifact, error)
Create creates a new Artifact model in the database. The given hash should be unique across all Artifact models created. The src should be the verbatim name of the Artifact from the build environment. The dst should be the name that is used for collecting the Artifact.
func (*ArtifactStore) Deleted ¶
func (s *ArtifactStore) Deleted(ids ...int64) error
Deleted marks all of the artifacts in the given list of ids as deleted. This will set the deleted_at column to the result of time.Now when this is called.
func (*ArtifactStore) Get ¶
func (s *ArtifactStore) Get(opts ...query.Option) (*Artifact, error)
Get returns a single Artifact model, applying each query.Option that is given.
func (*ArtifactStore) Load ¶
func (s *ArtifactStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load implements the database.Loader interface. Any models that are bound to the ArtifactStore will be applied during querying.
func (*ArtifactStore) New ¶
func (s *ArtifactStore) New() *Artifact
New returns a new Artifact binding any non-nil models to it from the current ArtifactStore.
type Build ¶
type Build struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` NamespaceID sql.NullInt64 `db:"namespace_id"` Number int64 `db:"number"` Manifest manifest.Manifest `db:"manifest"` Status runner.Status `db:"status"` Output sql.NullString `db:"output"` Secret sql.NullString `db:"secret"` CreatedAt time.Time `db:"created_at"` StartedAt sql.NullTime `db:"started_at"` FinishedAt sql.NullTime `db:"finished_at"` User *user.User `db:"-" json:"-"` Namespace *namespace.Namespace `db:"-" json:"-"` Driver *Driver `db:"-" json:"-"` Trigger *Trigger `db:"-" json:"-"` Tags []*Tag `db:"-" json:"-"` Stages []*Stage `db:"-" json:"-"` }
Build is the type that represents a build that has either run, or will be run.
func FromContext ¶
FromContext returns the Build model from the given context, if any.
func (*Build) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, namespace.Namespace, Trigger, Tag, Stage, or Driver.
func (*Build) Endpoint ¶
Endpoint implements the database.Model interface. If the current Build has a nil or zero value User bound model then an empty string is returned, otherwise the full Build endpoint is returned, for example,
/b/l.belardo/10
func (*Build) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Build values under each key. This will also include urls to the Build's objects, variables, jobs, artifacts, and tags. If any of the User, Namespace, or Trigger bound models exist on the Build, then the JSON representation of these models will be in the returned map, under the user, namespace, and trigger keys respectively.
func (*Build) Kill ¶
Kill kills the given build by publishing the build's secret to the given redis.Client.
func (*Build) SetPrimary ¶
SetPrimary implements the database.Model interface.
type Curator ¶
type Curator struct {
// contains filtered or unexported fields
}
Curator is used for removing old build artifacts whose total size exceed the configured limit.
func NewCurator ¶
NewCurator creates a new curator for cleaning up old artifacts from the given block store.
type Driver ¶
type Driver struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` Type driver.Type `db:"type"` Config manifest.Driver `db:"config"` Build *Build `db:"-"` }
Driver is the type that represents the driver being used by a build.
func (*Driver) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to Build.
func (*Driver) Endpoint ¶
Endpoint implements the database.Model interface. This returns an empty string.
func (*Driver) SetPrimary ¶
SetPrimary implements the database.Model interface.
type DriverStore ¶
type DriverStore struct { database.Store // Build is the bound Build model. If not nil this will bind the Build // model to any Driver models that are created. If not nil this will append // a WHERE clause on the build_id column for all SELECT queries performed. Build *Build }
DriverStore is the type for creating Driver models in the database.
func NewDriverStore ¶
func NewDriverStore(db *sqlx.DB, mm ...database.Model) *DriverStore
NewDriverStore returns a new DriverStore for querying the build_drivers table. Each database passed to this function will be bound to the returned DriverStore.
func (*DriverStore) All ¶
func (s *DriverStore) All(opts ...query.Option) ([]*Driver, error)
All returns a slice of Driver models, applying each query.Option that is given. The database.Where option is applied to the *Build bound database.
func (*DriverStore) Bind ¶
func (s *DriverStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the model if they are pointers to Build.
func (*DriverStore) Create ¶
func (s *DriverStore) Create(cfg map[string]string) (*Driver, error)
Create creates a new driver using the given configuration.
func (*DriverStore) Get ¶
func (s *DriverStore) Get(opts ...query.Option) (*Driver, error)
Get returns a single Driver database, applying each query.Option that is given. The database.Where option is applied to the *Build bound database.
func (*DriverStore) Load ¶
func (s *DriverStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Driver models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls DriverStore.All under the hood, so any bound models will impact the models being loaded.
func (*DriverStore) New ¶
func (s *DriverStore) New() *Driver
New returns a new Driver binding any non-nil models to it from the current DriverStore.
type Event ¶ added in v1.1.0
type Event struct { Build *Build // contains filtered or unexported fields }
type Form ¶
type Form struct { Manifest manifest.Manifest `schema:"manifest" json:"manifest"` Comment string `schema:"comment" json:"comment"` Tags tags `schema:"tags" json:"tags"` }
Form is the type that represents the input data for creating/submitting a build.
type Job ¶
type Job struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` StageID int64 `db:"stage_id"` Name string `db:"name"` Commands string `db:"commands"` Status runner.Status `db:"status"` Output sql.NullString `db:"output"` CreatedAt time.Time `db:"created_at"` StartedAt sql.NullTime `db:"started_at"` FinishedAt sql.NullTime `db:"finished_at"` Build *Build `db:"-"` Stage *Stage `db:"-"` Artifacts []*Artifact `db:"-"` }
Job is the type that represents a job that is either running, or has been run during a build.
func (*Job) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build, Stage, or Artifact models.
func (*Job) Endpoint ¶
Endpoint implements the database.Model interface. If the current Job has a nil or zero value Build bound model then an empty string is returned, otherwise the full Build endpoint is returned, suffixed with the Job endpoint, for example,
/b/l.belardo/10/jobs/create-driver
func (*Job) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Job's values under each key.
func (*Job) Job ¶
Job returns the underlying runner.Job of the current Job. This can then be passed to a runner.Driver for execution. It is expected for the Job's Artifact slice to be already loaded onto the current database.
func (*Job) SetPrimary ¶
SetPrimary implements the database.Model interface.
type JobStore ¶
JobStore is the type for creating and modifying Job models in the database.
func NewJobStore ¶
NewJobStore returns a new JobStore for querying the build_jobs table. Each database passed to this function will be bound to the returned JobStore.
func (*JobStore) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build, Stage, or Artifact.
func (*JobStore) Create ¶
Create creates a new Job model in the database with the given name and commands.
func (*JobStore) Finished ¶
Finished marks the Job model with the given id as finished in the database, with the given output and status.
func (*JobStore) Index ¶
Index returns the results from the jobs table depending on the values that are present in url.Values. Detailed below are the values that are used from the given url.Values,
name - This applies the database.Search query.Option using the value of name status - This applied the WhereStatus query.Option using the value of status
func (*JobStore) Load ¶
func (s *JobStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Job models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls JobStore.All under the hood, so any bound models will impact the models being loaded.
type Key ¶
type Key struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` KeyID sql.NullInt64 `db:"key_id"` Name string `db:"name"` Key []byte `db:"key"` Config string `db:"config"` Location string `db:"location"` Build *Build `db:"-"` }
Key is the type that represents an SSH key that has been placed into the build environment.
func (*Key) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to a Build model.
func (*Key) Endpoint ¶
Endpoint implements the database.Model interface. This returns an empty string.
func (*Key) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Key's values under each key.
func (*Key) SetPrimary ¶
SetPrimary implements the database.Model interface.
type KeyStore ¶
type KeyStore struct { database.Store Build *Build Key *key.Key // contains filtered or unexported fields }
KeyStore is the type for creating and modifying Key models in the database. The KeyStore type uses an underlying crypto.AESGCM for encrypting the SSH key itself when being stored in the database.
func NewKeyStore ¶
NewKeyStore returns a new KeyStore for querying the build_jobs table. Each database passed to this function will be bound to the returned JobStore.
func NewKeyStoreWithCrypto ¶ added in v1.1.0
NewKeyStoreWithblock is functionally the same as NewStore, however it sets the given crypto.AESGCM on the newly returned KeyStore.
func (*KeyStore) All ¶
All returns a slice of Key models, applying each query.Option that is given. Each database that is bound to the store will be applied to the list of query options via database.Where.
func (*KeyStore) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to a Build model.
func (*KeyStore) Copy ¶
Copy copies each given key.Key into a build Key, and returns the slice of newly created Key models.
func (*KeyStore) Get ¶
Get returns a single Key database, applying each query.Option that is given. Each database that is bound to the store will be applied to the list of query options via database.Where.
func (*KeyStore) Load ¶
func (s *KeyStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Key models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls KeyStore.All under the hood, so any bound models will impact the models being loaded.
type Object ¶
type Object struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` ObjectID sql.NullInt64 `db:"object_id"` Source string `db:"source"` Name string `db:"name"` Placed bool `db:"placed"` CreatedAt time.Time `db:"created_at"` Build *Build `db:"-"` Object *object.Object `db:"-"` }
Object is the type that represents a file that has been placed into a build environment for a given build. This contains metadata about the file that was placed.
func (*Object) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or object.Object.
func (*Object) Endpoint ¶
Endpoint implements the database.Model interface. This returns an empty string.
func (*Object) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Object's values under each key. If any of the Build, or Object bound models exist on the Object, then the JSON representation of these models will be in the returned map, under the build, and object keys respectively.
func (*Object) SetPrimary ¶
SetPrimary implements the database.Model interface.
type ObjectStore ¶
type ObjectStore struct { database.Store // Build is the bound Build model. If not nil this will bind the Build // model to any Object models that are created. If not nil this will // append a WHERE clause on the build_id column for all SELECT queries // performed. Build *Build // Object is the bound object.Object model. If not nil this will bind the // object.Object model to any Object models that are created. If not nil // this will append a WHERE clause on the object_id column for all SELECT // queries performed. Object *object.Object // contains filtered or unexported fields }
ObjectStore is the type for creating and modifying Object models in the database. The ObjectStore type can have an underlying runner.Placer implementation that can allow for it to be used for placing objects into a build environment.
func NewObjectStore ¶
func NewObjectStore(db *sqlx.DB, mm ...database.Model) *ObjectStore
NewObjectStore returns a new ObjectStore for querying the build_objects table. Each model passed to this function will be bound to the returned ObjectStore.
func NewObjectStoreWithPlacer ¶
NewObjectStoreWithCollector returns a new ObjectStore with the given runner.Placer to use for object placement.
func (*ObjectStore) All ¶
func (s *ObjectStore) All(opts ...query.Option) ([]*Object, error)
All returns a slice of Object models, applying each query.Option that is given.
func (*ObjectStore) Bind ¶
func (s *ObjectStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or object.Object.
func (*ObjectStore) Create ¶
func (s *ObjectStore) Create(objectId int64, name, dst string) (*Object, error)
func (*ObjectStore) Get ¶
func (s *ObjectStore) Get(opts ...query.Option) (*Object, error)
Get returns a single Object model, applying each query.Option that is given.
func (*ObjectStore) Load ¶
func (s *ObjectStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Object models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls ObjectStore.All under the hood, so any bound models will impact the models being loaded.
func (*ObjectStore) New ¶
func (s *ObjectStore) New() *Object
New returns a new Object binding any non-nil models to it from the current ObjectStore.
type Payload ¶
type Payload struct { Host string // Host is the server hostname the build was submitted to BuildID int64 // BuildID is the ID of the build }
Payload is how the build is put onto the queue. This struct will be encoded via encoding/gob, and submitted to Redis.
type Stage ¶
type Stage struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` Name string `db:"name"` CanFail bool `db:"can_fail"` Status runner.Status `db:"status"` CreatedAt time.Time `db:"created_at"` StartedAt sql.NullTime `db:"started_at"` FinishedAt sql.NullTime `db:"finished_at"` Build *Build `db:"-"` Jobs []*Job `db:"-"` }
Stage is the type that represents a stage that is in a build.
func (*Stage) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or Stage.
func (*Stage) Endpoint ¶
Endpoint implements the database.Model interface. If the current Stage has a nil or zero value Build bound model then an empty string is returned, otherwise the full Build endpoint is returned, suffixed with the Stage endpoint, for example,
/b/l.belardo/10/stages/2
func (*Stage) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Stage's values under each key. If the Build bound model exists on the Stage, then the JSON representation of that model will be in the returned map under the build key.
func (*Stage) SetPrimary ¶
SetPrimary implements the database.Model interface.
type StageStore ¶
type StageStore struct { database.Store // Build is the bound Build model. If not nil this will bind the Build // model to any Stage models that are created. If not nil this will // append a WHERE clause on the build_id column for all SELECT queries // performed. Build *Build }
StageStore is the type for creating and modifying Stage models in the database.
func NewStageStore ¶
func NewStageStore(db *sqlx.DB, mm ...database.Model) *StageStore
NewStageStore returns a new StageStore for querying the build_stages table. Each database passed to this function will be bound to the returned StageStore.
func (StageStore) All ¶
func (s StageStore) All(opts ...query.Option) ([]*Stage, error)
All returns a slice of Stage models, applying each query.Option that is given.
func (*StageStore) Bind ¶
func (s *StageStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or Stage.
func (*StageStore) Create ¶
func (s *StageStore) Create(name string, canFail bool) (*Stage, error)
Create creates a new Stage model in the database with the name, and whether or not it can fail.
func (StageStore) Load ¶
func (s StageStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Stage models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls StageStore.All under the hood, so any bound models will impact the models being loaded.
func (StageStore) New ¶
func (s StageStore) New() *Stage
New returns a new Stage binding any non-nil models to it from the current StageStore.
type Store ¶
type Store struct { database.Store // User is the bound User model. If not nil this will bind the User model to // any Build models that are created. If not nil this will be passed to the // namespace.WhereCollaborator query option on each SELECT query performed. User *user.User // Namespace is the bound Namespace model. If not nil this will bind the // Namespace model to any Build models that are created. If not nil this // will append a WHERE clause on the namespace_id column for all SELECT // queries performed. Namespace *namespace.Namespace // contains filtered or unexported fields }
Store is the type for creating and modifying Build models in the database. The Store type can have an underlying hasher.Hasher that is used for generating artifact hashes.
func NewStore ¶
NewStore returns a new Store for querying the builds table. Each model passed to this function will be bound to the returned Store.
func NewStoreWithHasher ¶
NewStoreWithHasher functionally does the same as NewStore, however it sets the given hasher on the newly returned store for hashing of Artifact names.
func (*Store) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, namespace.Namespace, Trigger, Tag, Stage, or Driver.
func (*Store) Create ¶
Create takes the given manifest.Manifest, Trigger, and tags, and creates a new Build model in the database. This will also create a Trigger, and tags once the Build has been created in the database.
func (*Store) Finished ¶
Finished marks the build of the given id as finished, setting the output of the build and status to the given values.
func (*Store) Index ¶
Index returns the paginated results from the builds table depending on the values that are present in url.Values. Detailed below are the values that are used from the given url.Values,
tag - This applies the WhereTag query.Option using the value of tag search - This applies the WhereSearch query.Option using the value of search status - This applies the WhereStatus query.Option using the value of status
func (*Store) Load ¶
func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Build models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls Store.All under the hood, so any bound models will impact the models being loaded.
func (*Store) New ¶
New returns a new Build binding any non-nil models to it from the current Store.
func (*Store) Orphan ¶ added in v1.1.0
Orphan marks the given build as orphaned, and clears down the output of the build and its jobs. An orphaned build happens when the worker is restarted whilst a build is processing.
func (*Store) Paginate ¶
Paginate returns the database.Paginator for the builds table for the given page.
type Tag ¶
type Tag struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` BuildID int64 `db:"build_id"` Name string `db:"name"` CreatedAt time.Time `db:"created_at"` User *user.User `db:"-"` Build *Build `db:"-"` }
Tag is the type that represents a tag on a build.
func (*Tag) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or user.User models.
func (Tag) Endpoint ¶
Endpoint implements the database.Model interface. If the current Tag has a nil or zero value Tag bound model then an emtpy string is returned, otherwise the full Build endpoint is returned, suffixed with the Tag endpoint, for example,
/b/l.belardo/10/tags/qemu
func (*Tag) JSON ¶
JSON implements the database.Model interface. This will return reutrn a map with the current Tag's values under each key. If the User or Build bound models are not zero, then the JSON representation of each will be in the returned map under the user and build keys respectively.
func (*Tag) SetPrimary ¶
SetPrimary implements the database.Model interface.
type TagEvent ¶ added in v1.1.0
type TagForm ¶
type TagForm struct {
Tags tags `schema:"tags"`
}
TagForm is the type that represents the input data for creating tags on a build.
func (*TagForm) Fields ¶
Fields is a stub method to statisfy the form.Form interface. It returns an empty map.
func (*TagForm) UnmarshalJSON ¶
UnmarshalJSON will attempt to unmarshal the given byte slice into a slice of strings.
type TagStore ¶
TagStore is the type for creating and modifying Tag models in the database.
func NewTagStore ¶
NewTagStore returns a new TagStore for querying the build_tags table. Each database passed to this function will be bound to the returned TagStore.
func (*TagStore) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or user.User models.
func (*TagStore) Create ¶
Create takes the given names, and creates a Tag for each for the given build ID, and user ID. A slice of the created Tag models are returned.
func (TagStore) Load ¶
func (s TagStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Job models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls JobStore.All under the hood, so any bound models will impact the models being loaded.
type Trigger ¶
type Trigger struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` ProviderID sql.NullInt64 `db:"provider_id"` RepoID sql.NullInt64 `db:"repo_id"` Type TriggerType `db:"type"` Comment string `db:"comment"` Data triggerData `db:"data"` CreatedAt time.Time `db:"created_at"` Build *Build `db:"-" gob:"-"` }
Trigger is the type that represents what triggered a build.
func (*Trigger) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to a Build model.
func (Trigger) CommentBody ¶
CommentBody parses the trigger comment to get the body of the comment. This will typically return the lines of the comment that appear after the first newline character that is found. If there is no newline character, and the trigger comment itself is less than 72 characters in length, then nothing is returned. The first 72 characters are summed to be the title of the comment.
func (Trigger) CommentTitle ¶
CommentTitle parses the trigger comment to get the title of the comment. This treats the first line of the trigger comment as the title. If that first line is longer than 72 characters, then only the first 72 characters will be returned.
func (*Trigger) Endpoint ¶
Endpoint is a stub to fulfill the database.Model interface. It returns an empty string.
func (*Trigger) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Trigger's values under each key.
func (*Trigger) SetPrimary ¶
type TriggerStore ¶
TriggerStore is the type for creating and modifying Trigger models in the database.
func NewTriggerStore ¶
func NewTriggerStore(db *sqlx.DB, mm ...database.Model) *TriggerStore
NewTriggerStore returns a new TriggerStore for querying the build_triggers table. Each database passed to this function will be bound to the returned TriggerStore.
func (TriggerStore) All ¶
func (s TriggerStore) All(opts ...query.Option) ([]*Trigger, error)
All returns a slice of Trigger models, applying each query.Option that is given. The database.Where option is used on the Build bound database to limit the query to those relations.
func (*TriggerStore) Bind ¶
func (s *TriggerStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the models if they are pointers to a Build model.
func (*TriggerStore) Create ¶
func (s *TriggerStore) Create(tt ...*Trigger) error
func (TriggerStore) Load ¶
func (s TriggerStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Trigger models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls StageStore.All under the hood, so any bound models will impact the models being loaded.
type TriggerType ¶
type TriggerType uint8
const ( // There are three different trigger types for a build trigger, // Manual - for when a build was manually submitted for either via the API // or UI. // // Push - for when a build was triggered via a commit hook. // Pull - for when a build was triggered via a pull-request hook. // Schedule - for when a build was triggered via a cron. Manual TriggerType = iota // manual Push // push Pull // pull Schedule // schedule )
func (*TriggerType) Scan ¶
func (t *TriggerType) Scan(val interface{}) error
func (TriggerType) String ¶
func (i TriggerType) String() string
func (*TriggerType) UnmarshalText ¶
func (t *TriggerType) UnmarshalText(b []byte) error
type Variable ¶
type Variable struct { ID int64 `db:"id"` BuildID int64 `db:"build_id"` VariableID sql.NullInt64 `db:"variable_id"` Key string `db:"key"` Value string `db:"value"` Build *Build `db:"-"` Variable *variable.Variable `db:"-"` }
Variable is the type that represents a variable that has been set on a build.
func (*Variable) Bind ¶
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either a Build or variable.Variable model.
func (*Variable) Endpoint ¶
Endpoint implements the database.Model interface. This will return an empty string.
func (*Variable) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Variable's values. If the Build bound model exists on the current Variable then the JSON representation will be in the returned map under the build key.
func (*Variable) SetPrimary ¶
SetPrimary implements the database.Model interface.
type VariableStore ¶
VariableStore is the type for creating and modifying Variable models in the database.
func NewVariableStore ¶
func NewVariableStore(db *sqlx.DB, mm ...database.Model) *VariableStore
NewVariableStore returns a new VariableStore for querying the build_variables table. Each database passed to this function will be bound to the returned VariableStore.
func (VariableStore) All ¶
func (s VariableStore) All(opts ...query.Option) ([]*Variable, error)
All returns a slice of Variable models, applying each query.Option that is given.
func (*VariableStore) Bind ¶
func (s *VariableStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the models if they are pointers to either Build or variable.Variable.
func (*VariableStore) Copy ¶
func (s *VariableStore) Copy(vv ...*variable.Variable) ([]*Variable, error)
Copy copies each given variable.Variable into a build Variable, and returns the slice of newly created Variable models.
func (*VariableStore) Create ¶
func (s *VariableStore) Create(key, val string) (*Variable, error)
Create creates a new Variable with the given key and val.
func (VariableStore) Load ¶
func (s VariableStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Variable models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls StageStore.All under the hood, so any bound models will impact the models being loaded.
func (VariableStore) New ¶
func (s VariableStore) New() *Variable
New returns a new Variable binding any non-nil models to it from the current VariableStore.