brigade

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: Apache-2.0 Imports: 5 Imported by: 30

Documentation

Overview

Package brigade provides the common types for brigade components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProjectID

func ProjectID(id string) string

ProjectID will encode a project name.

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"`
	// ShortTitle is an optional field for a short (and not necessarily unique)
	// string value that can be added to a build by a gateway to ascribe context
	// that may be meaningful to human users. For instance, the GitHub gateway
	// COULD label a build triggered by a pull request with the title or number of
	// that pull request.
	ShortTitle string `json:"short_title"`
	// LongTitle is an optional field for a longer (and not necessarily unique)
	// string value that can be added to a build by a gateway to ascribe context
	// that may be meaningful to human users. For instance, the GitHub gateway
	// COULD label a build triggered by a pull request with the title or number of
	// that pull request.
	LongTitle string `json:"long_title"`
	// CloneURL is the URL at which the repository can be cloned.
	// This is optional at the build-level. If set, it overrides the same setting
	// at the projet-level.
	CloneURL string `json:"clone_url"`
	// Revision describes a vcs revision.
	Revision *Revision `json:"revision"`
	// Payload is the raw data as received by the webhook.
	Payload []byte `json:"payload"`
	// Script is the brigadeJS to be executed.
	Script []byte `json:"script"`
	// Config is a JSON file representing Brigade configuration,
	// including JS dependencies and other information
	Config []byte `json:"config"`
	// 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"`
	// LogLevel determines what level of logging from the Javascript
	// to print to console.
	LogLevel string `json:"log_level,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.

func (JobStatus) String added in v0.13.0

func (j JobStatus) String() string

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"`
	// BuildStorageCache is the storage class used for build storage.
	BuildStorageClass string `json:"buildStorageClass"`
	// CacheStorageClass is the storage class used for caching jobs.
	CacheStorageClass string `json:"cacheStorageClass"`
	// AllowSecretKeyRef controls if secretKeyRefs can be used in the job's environment
	AllowSecretKeyRef bool `json:"allowSecretKeyRef"`
	// ServiceAccount is the service account to use for this project
	ServiceAccount string `json:"serviceAccount"`
}

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"`
	// DefaultScriptName is the name of the configmap where the script is stored.
	DefaultScriptName string `json:"defaultScriptName"`
	// DefaultConfig is a json config used by default when missing from the repo
	DefaultConfig string `json:"defaultConfig"`
	// DefaultConfigName is the name of the configmap where the config is stored.
	DefaultConfigName string `json:"defaultConfigName"`
	// Kubernetes holds information about Kubernetes
	Kubernetes Kubernetes `json:"kubernetes"`
	// SharedSecret is the GitHub shared key
	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"`

	// InitGitSubmodules initializes Git submodules in VCS if true.
	InitGitSubmodules bool `json:"initGitSubmodules"`

	// AllowPrivilegedJobs allows jobs to use privileged mode.
	AllowPrivilegedJobs bool `json:"allowPrivilegedJobs"`

	// AllowHostMounts lets the worker use host mounted volumes
	AllowHostMounts bool `json:"allowHostMounts"`

	// ImagePullSecrets is a comma-separated list of image pull secrets
	ImagePullSecrets string `json:"imagePullSecrets"`

	// WorkerCommand is a string command that can be issued to the worker image.
	// This is an alternative to the default 'yarn -s start' command (or other
	// globally configured command) usually issued.
	WorkerCommand string `json:"workerCommand"`

	// BrigadejsPath contains the path for the Brigade.js file in the source repo
	BrigadejsPath string `json:"brigadejsPath"`

	// BrigadeConfigPath contains the path for the brigade.json file in the source repo
	BrigadeConfigPath string `json:"brigadeConfigPath"`

	// GenericGatewaySecret is a string that contains the access code used by API Server to authenticate generic Gateway requests
	GenericGatewaySecret string `json:"genericGatewaySecret"`
}

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:"-"`
	SSHCert 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

type SecretsMap map[string]interface{}

SecretsMap is a map[string]interface{} 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

Jump to

Keyboard shortcuts

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