Documentation
¶
Overview ¶
Package brigade provides the common types for brigade components.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Build ¶
type Build struct {
// ID is the unique ID for a webhook event.
ID string `json:"id"`
// ProjectID is the computed name of the project (brigade-aeff2343a3234ff)
ProjectID string `json:"project_id"`
// Type is the event type (push, pull_request, tag, etc.)
Type string `json:"type"`
// Provider is the name of the service that caused the event (github, vsts, cron, ...)
Provider string `json:"provider"`
// Revision describes a vcs revision.
Revision *Revision `json:"revision"`
// Payload is the raw data as received by the webhook.
Payload []byte `json:"payload,omitempty"`
// Script is the brigadeJS to be executed.
Script []byte `json:"script,omityempty"`
// Worker is the master job that is running this build.
// The Worker's properties (creation time, state, exit code, and so on)
// reflect a "roll-up" of the job.
// This property is not guaranteed to be set, and may be nil.
Worker *Worker `json:"worker,omitempty"`
}
Build represents an invocation of an event in Brigade.
Each build has a unique ID, and is tied to a project, as well as an event type.
type Github ¶
type Github struct {
// Token is used for oauth2 for client interactions.
Token string `json:"-"`
// BaseURL is used to construct an Enterprise GitHub client.
// If not supplied, the assumption is that we are connecting to
// github.com.
BaseURL string `json:"baseURL"`
// UploadURL is the upload URL to be used for GitHub enterprise.
// Typically, it is the same as the BaseURL.
UploadURL string `json:"uploadURL"`
}
Github describes the Github configuration for a project.
type Job ¶
type Job struct {
// ID is the name for the pod running this job
ID string `json:"id"`
// Name is the name for the job
Name string `json:"name"`
// Image is the execution environment running the job
Image string `json:"image"`
// CreationTime is a timestamp representing the server time when this object was
// created. It is not guaranteed to be set in happens-before order across separate operations.
CreationTime time.Time `json:"creation_time"`
// StartTime is the time the job started.
StartTime time.Time `json:"start_time"`
// EndTime is the time the job completed. This may not be present
// if the job has not completed.
EndTime time.Time `json:"end_time"`
// ExitCode is the exit code of the job. This may not be present
// if the job has not completed.
ExitCode int32 `json:"exit_code"`
// Status is a textual representation of the job's running status
Status JobStatus `json:"status"`
}
Job is a single job that is executed when a build is triggered for an event.
type JobStatus ¶
type JobStatus string
JobStatus is a label for the condition of a Job at the current time.
const ( // JobPending means the job has been accepted by the system, but one or more of the containers // has not been started. This includes time before being bound to a node, as well as time spent // pulling images onto the host. JobPending JobStatus = "Pending" // JobRunning means the job has been bound to a node and all of the containers have been started. // At least one container is still running or is in the process of being restarted. JobRunning JobStatus = "Running" // JobSucceeded means that all containers in the job have voluntarily terminated // with a container exit code of 0, and the system is not going to restart any of these containers. JobSucceeded JobStatus = "Succeeded" // JobFailed means that all containers in the job have terminated, and at least one container has // terminated in a failure (exited with a non-zero exit code or was stopped by the system). JobFailed JobStatus = "Failed" // JobUnknown means that for some reason the state of the job could not be obtained, typically due // to an error in communicating with the host of the job. JobUnknown JobStatus = "Unknown" )
These are the valid statuses of jobs.
type Kubernetes ¶
type Kubernetes struct {
// Namespace is the namespace of this project.
Namespace string `json:"namespace"`
// VCSSidecar is the image name/tag for the sidecar that pulls VCS data
VCSSidecar string `json:"vcsSidecar"`
// BuildStorageSize is the size of the build shared storage used by the jobs
BuildStorageSize string `json:"buildStorageSize"`
}
Kubernetes describes the Kubernetes configuration for a project.
type Project ¶
type Project struct {
// ID is the computed name of the project (brigade-aeff2343a3234ff)
ID string `json:"id"`
// Name is the human readable name of project.
Name string `json:"name"`
// Repo describes the repository where the source code is stored.
Repo Repo `json:"repo"`
// DefaultScript is a snippet of js used by default when the Repo misses brigade.js in it
DefaultScript string `json:"defaultScript"`
// Kubernetes holds information about Kubernetes
Kubernetes Kubernetes `json:"kubernetes"`
SharedSecret string `json:"-"`
// Github holds information about Github.
Github Github `json:"github"`
// Secrets is environment variables for brigade.js
Secrets SecretsMap `json:"secrets"`
// Worker holds a set of project-specific worker settings which takes precedence over brigade-wide settings
Worker WorkerConfig `json:"worker"`
}
Project describes a Brigade project
This is an internal representation of a project, and contains data that should not be made available to the JavaScript runtime.
type Repo ¶
type Repo struct {
// Name of the repository. For GitHub, this is of the form
// `github.com/org/name` or `github.com/user/name`
Name string `json:"name"`
// CloneURL is the URL at which the repository can be cloned
// Traditionally, this is an HTTPS URL.
CloneURL string `json:"cloneURL"`
// SSHKey is the auth string for SSH-based cloning
SSHKey string `json:"-"`
}
Repo describes a Git repository.
type Revision ¶ added in v0.10.0
type Revision struct {
// Commit is the ID of the VCS version, such as the Git commit SHA.
Commit string `json:"commit"`
// Ref is the symbolic ref name. (refs/heads/master, refs/pull/12/head, refs/tags/v0.1.0)
Ref string `json:"ref"`
}
Revision describes a vcs revision.
type SecretsMap ¶ added in v0.5.0
SecretsMap is a map[string]string for storing secrets.
When secrets are marshaled, values will be redacted.
func (SecretsMap) MarshalJSON ¶ added in v0.5.0
func (s SecretsMap) MarshalJSON() ([]byte, error)
MarshalJSON redacts secret values when encoding to JSON.
type Worker ¶
type Worker struct {
// ID is the name for the pod running this job
ID string `json:"id"`
// BuildID is the build ID (ULID).
BuildID string `json:"build_id"`
// ProjectID is the computed name of the project (brigade-aeff2343a3234ff)
ProjectID string `json:"project_id"`
// StartTime is the time the worker started.
StartTime time.Time `json:"start_time"`
// EndTime is the time the worker completed. This may not be present
// if the job has not completed.
EndTime time.Time `json:"end_time"`
// ExitCode is the exit code of the job. This may not be present
// if the job has not completed.
ExitCode int32 `json:"exit_code"`
// Status is a textual representation of the job's running status
Status JobStatus `json:"status"`
}
Worker represents the worker that runs a build. A worker executes (and wraps) the jobs in a build.
type WorkerConfig ¶ added in v0.10.0
type WorkerConfig struct {
// Registry is the composition of:
// - the docker registry hostname(e.g. quay.io for quay and none for dockerhub)
// - docker repository(username or organizaton name)
// parts of a docker image reference
Registry string `json:"registry"`
// Name is the name of a docker image. For example, `nginx` is the name of `nginx:latest`
Name string `json:"name"`
// Tag is the tag of a docker image. For example, `latest` is the tag of `nginx:latest`
Tag string `json:"tag"`
// PullPolicy specifies when you want to pull the docker image for brigade-worker
PullPolicy string `json:"pullPolicy"`
}
WorkerConfig overrides what is specified under the `worker` key in brigade-wide config
func (WorkerConfig) Image ¶ added in v0.10.0
func (c WorkerConfig) Image() string
Image returns the full worker image name