Documentation ¶
Index ¶
- Constants
- Variables
- func GetJobHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func GetLogHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func ListJobsHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func ListOwnersHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func ListReposHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func NewJobHandler(c web.C, w http.ResponseWriter, r *http.Request)
- func Run(conf Config)
- func RunLocal(path string, conf Config)
- func Uint64ToBytes(x uint64) []byte
- type BoltJobLogger
- type BoltJobStore
- func (s *BoltJobStore) GetByNumber(owner, repo string, number uint64) (*Job, error)
- func (s *BoltJobStore) GetLogger(j *Job) JobLogger
- func (s *BoltJobStore) List(owner, repo string) ([]*Job, error)
- func (s *BoltJobStore) ListOwners() ([]string, error)
- func (s *BoltJobStore) ListRepos(owner string) ([]string, error)
- func (s *BoltJobStore) Save(j *Job) error
- type Config
- type ContainerConfig
- type DockerExecutor
- func (e DockerExecutor) Attach(id string, stdout io.Writer, stderr io.Writer) error
- func (e DockerExecutor) Build(input io.Reader, output io.Writer) (string, error)
- func (e DockerExecutor) Kill(id string) error
- func (e DockerExecutor) Run(opts RunContainerOpts) (string, error)
- func (e DockerExecutor) Wait(id string) (int, error)
- type Executor
- type InMemoryJobStore
- func (s *InMemoryJobStore) GetByNumber(owner, repo string, number uint64) (*Job, error)
- func (s *InMemoryJobStore) GetLogger(j *Job) JobLogger
- func (s *InMemoryJobStore) List(owner, repo string) ([]*Job, error)
- func (s *InMemoryJobStore) ListOwners() ([]string, error)
- func (s *InMemoryJobStore) ListRepos(owner string) ([]string, error)
- func (s *InMemoryJobStore) Save(j *Job) error
- type Job
- type JobConfig
- type JobLogger
- type JobRequest
- type JobStore
- type RunContainerOpts
- type WriterLogger
Constants ¶
const ( // GitImage is the Docker image used for the working directory and fetching sources. GitImage = "radial/busyboxplus:git" // BuildDir is the path for project sources in the working directory container. BuildDir = "/cion/build" // ArtifactsDir is the path to the artifacts directory in the working directory container. ArtifactsDir = "/cion/artifacts" )
Variables ¶
var ( JobsBucket = []byte("jobs") JobRefsBucket = []byte("jobrefs") )
Functions ¶
func GetJobHandler ¶
func GetLogHandler ¶
func ListJobsHandler ¶
func ListOwnersHandler ¶
func ListReposHandler ¶
func NewJobHandler ¶
func Uint64ToBytes ¶
Types ¶
type BoltJobLogger ¶
type BoltJobLogger struct {
// contains filtered or unexported fields
}
func (BoltJobLogger) WriteStep ¶
func (l BoltJobLogger) WriteStep(name string) error
type BoltJobStore ¶
type BoltJobStore struct {
// contains filtered or unexported fields
}
func NewBoltJobStore ¶
func NewBoltJobStore(path string) (*BoltJobStore, error)
func (*BoltJobStore) GetByNumber ¶
func (s *BoltJobStore) GetByNumber(owner, repo string, number uint64) (*Job, error)
func (*BoltJobStore) GetLogger ¶
func (s *BoltJobStore) GetLogger(j *Job) JobLogger
func (*BoltJobStore) ListOwners ¶
func (s *BoltJobStore) ListOwners() ([]string, error)
func (*BoltJobStore) Save ¶
func (s *BoltJobStore) Save(j *Job) error
Save writes job data to various buckets in the Bolt database. We use this nesting pattern for buckets:
jobs -> (owner) -> (repo) -> logs_(job number)
The actual data for a job is saved to the bucket for its repo, and its logs are stored in the logs_<number> sub-bucket.
type Config ¶
type Config struct { Executor Executor JobStore JobStore GitHubClientID string GitHubSecret string }
func ConfigureLocal ¶
type ContainerConfig ¶
type ContainerConfig struct { Image string Cmd []string Env []string Ports []string Privileged bool }
ContainerConfig is a container configuration defined in .cion.yml.
type DockerExecutor ¶
type DockerExecutor struct {
// contains filtered or unexported fields
}
DockerExecutor is an Executor that runs against a single Docker host.
func NewDockerExecutor ¶
func NewDockerExecutor(endpoint, certPath string) (*DockerExecutor, error)
func (DockerExecutor) Kill ¶
func (e DockerExecutor) Kill(id string) error
func (DockerExecutor) Run ¶
func (e DockerExecutor) Run(opts RunContainerOpts) (string, error)
type Executor ¶
type Executor interface { // Run starts a Docker container and returns the container name if successful. Run(opts RunContainerOpts) (string, error) // Attach attaches to a container and writes stdout/stderr to the provided writers. Attach(id string, stdout io.Writer, stderr io.Writer) error // Wait blocks until a container exits, and returns its exit code. Wait(id string) (int, error) // Kill kills a container dead. Kill(id string) error // Build builds a Docker image and returns the image name if successful. Build(input io.Reader, output io.Writer) (string, error) }
An Executor runs Docker containers against a Docker host or Docker-like cluster.
type InMemoryJobStore ¶
type InMemoryJobStore struct {
// contains filtered or unexported fields
}
InMemoryJobStore is a mock JobStore that only stores jobs in memory and writes logs directly to stdout. It is only meant to be used for testing.
func NewInMemoryJobStore ¶
func NewInMemoryJobStore() *InMemoryJobStore
func (*InMemoryJobStore) GetByNumber ¶
func (s *InMemoryJobStore) GetByNumber(owner, repo string, number uint64) (*Job, error)
func (*InMemoryJobStore) GetLogger ¶
func (s *InMemoryJobStore) GetLogger(j *Job) JobLogger
func (*InMemoryJobStore) ListOwners ¶
func (s *InMemoryJobStore) ListOwners() ([]string, error)
func (*InMemoryJobStore) ListRepos ¶
func (s *InMemoryJobStore) ListRepos(owner string) ([]string, error)
func (*InMemoryJobStore) Save ¶
func (s *InMemoryJobStore) Save(j *Job) error
type Job ¶
type Job struct { Number uint64 Owner string Repo string Branch string SHA string LocalPath string StartedAt *time.Time EndedAt *time.Time Success bool }
Job represents the job data that should be persisted to a JobStore.
type JobConfig ¶
type JobConfig struct { Build ContainerConfig Release ContainerConfig Services map[string]ContainerConfig }
JobConfig is the job configuration defined by .cion.yml.
type JobLogger ¶
type JobLogger interface { io.Writer io.WriterTo // WriteStep writes a transition to a new build step to the log. All subsequent writes are // assumed to be part of the new build step, until another new step is written. WriteStep(name string) error }
JobLogger provides an io.Writer interface for writing build logs for a job.
type JobRequest ¶
type JobRequest struct { Job *Job Executor Executor Store JobStore GitHubClientID string GitHubSecret string }
JobRequest defines a job that needs to be run and the dependencies needed to run it.
func (JobRequest) Run ¶
func (r JobRequest) Run()
Run executes a JobRequest and logs the results to the JobStore.
type JobStore ¶
type JobStore interface { // GetByNumber gets a job for the given owner/repo/branch by its number. GetByNumber(owner, repo string, number uint64) (*Job, error) // ListOwners returns a list of all the repo owners that have jobs. ListOwners() ([]string, error) // ListRepos returns a list of all the repos for a given owner. ListRepos(owner string) ([]string, error) // List gets all the jobs for the given owner/repo. List(owner, repo string) ([]*Job, error) // Save persists a job to storage. If the job doesn't have a number yet, it is assigned the // next incrementing job number for the repo. Save(j *Job) error // GetLogger gets the JobLogger to write logs for a job. GetLogger(j *Job) JobLogger }
JobStore write and reads jobs and job logs from persistent storage.
type RunContainerOpts ¶
type RunContainerOpts struct { // Image is the name of the Docker image to run. Image string // Cmd is the command to run in the container. Cmd []string // Env is a list of environment variables for the container, in the form "KEY=value". Env []string // Volumes is a list of volumes to create in the container. Volumes []string // Links is a list of existing containers that should be linked into the new container, // in the form "container_nname:alias". Links []string // VolumesFrom is a list of existing containers whose volumes should be mounted in the new // container, in the form "container_name[:ro|:rw]". VolumesFrom []string // Privileged specifies whether the container has extended privileges. Privileged bool // WorkingDir is the working directory in the container. WorkingDir string // Ports is a list of container ports to expose, in the format <port>/<tcp|udp>. Ports []string // LocalImage specifies whether the image was built locally (so we shouldn't try to pull it // from a remote repo). LocalImage bool }
RunContainerOpts are options for running a new container.
type WriterLogger ¶
type WriterLogger struct {
// contains filtered or unexported fields
}
func NewWriterLogger ¶
func NewWriterLogger(w io.Writer) WriterLogger
func (WriterLogger) WriteStep ¶
func (wl WriterLogger) WriteStep(name string) error