werft

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2020 License: MIT Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PathWerftConfig is the path relative to the repo root where we expect to find the werft config YAML
	PathWerftConfig = ".werft/config.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// BaseURL is the URL this service is available on (e.g. https://werft.some-domain.com)
	BaseURL string `yaml:"baseURL,omitempty"`

	// WorkspaceNodePathPrefix is the location on the node where we place the builds
	WorkspaceNodePathPrefix string `yaml:"workspaceNodePathPrefix,omitempty"`

	// CleanupJobSpec is a podspec YAML which forms the basis for cleanup jobs.
	// Can be empty, in which clean up jobs will use a default.
	CleanupJobSpec *configPodSpec `yaml:"cleanupJobSpec,omitempty"`

	// Enables the webui debug proxy pointing to this address
	DebugProxy string
}

Config configures the behaviour of the service

type ContentProvider

type ContentProvider interface {
	// InitContainer builds the container that will initialize the job content.
	// The VolumeMount for /workspace is added by the caller.
	// Name and ImagePullPolicy will be overwriten.
	InitContainer() (*corev1.Container, error)

	// Serve provides additional services required during initialization.
	// This function is expected to return immediately.
	Serve(jobName string) error
}

ContentProvider provides access to job workspace content

type FileProvider

type FileProvider interface {
	// Download provides access to a single file
	Download(ctx context.Context, path string) (io.ReadCloser, error)
}

FileProvider provides access to a single file

type GitCredentialHelper

type GitCredentialHelper func(ctx context.Context) (user string, pass string, err error)

GitCredentialHelper can authenticate provide authentication credentials for a repository

type GitHubContentProvider

type GitHubContentProvider struct {
	Owner    string
	Repo     string
	Revision string
	Client   *github.Client
	Auth     GitCredentialHelper
	Sideload *GitHubContentProviderSideload
}

GitHubContentProvider provides access to GitHub content

func (*GitHubContentProvider) Download

func (gcp *GitHubContentProvider) Download(ctx context.Context, path string) (io.ReadCloser, error)

Download provides access to a single file

func (*GitHubContentProvider) InitContainer

func (gcp *GitHubContentProvider) InitContainer() (*corev1.Container, error)

InitContainer builds the container that will initialize the job content.

func (*GitHubContentProvider) Serve

func (gcp *GitHubContentProvider) Serve(jobName string) error

Serve provides additional services required during initialization.

type GitHubContentProviderSideload

type GitHubContentProviderSideload struct {
	TarStream io.Reader

	Namespace  string
	Kubeconfig *rest.Config
	Clientset  kubernetes.Interface
}

GitHubContentProviderSideload enables side-loading of files after a Git clone

type GitHubSetup

type GitHubSetup struct {
	WebhookSecret []byte
	Client        *github.Client
	Auth          GitCredentialHelper
}

GitHubSetup sets up the access to GitHub

type LocalContentProvider

type LocalContentProvider struct {
	TarStream io.Reader

	Namespace  string
	Kubeconfig *rest.Config
	Clientset  kubernetes.Interface
}

LocalContentProvider provides access to local files

func (*LocalContentProvider) InitContainer

func (lcp *LocalContentProvider) InitContainer() (*corev1.Container, error)

InitContainer builds the container that will initialize the job content.

func (*LocalContentProvider) Serve

func (lcp *LocalContentProvider) Serve(jobName string) error

Serve provides additional services required during initialization.

type Service

type Service struct {
	Logs     store.Logs
	Jobs     store.Jobs
	Groups   store.NumberGroup
	Executor *executor.Executor
	Cutter   logcutter.Cutter
	GitHub   GitHubSetup

	Config Config
	// contains filtered or unexported fields
}

Service ties everything together

func (*Service) GetJob

func (srv *Service) GetJob(ctx context.Context, req *v1.GetJobRequest) (resp *v1.GetJobResponse, err error)

GetJob returns the information about a particular job

func (*Service) HandleGithubWebhook

func (srv *Service) HandleGithubWebhook(w http.ResponseWriter, r *http.Request)

HandleGithubWebhook handles incoming Github events

func (*Service) ListJobs

func (srv *Service) ListJobs(ctx context.Context, req *v1.ListJobsRequest) (resp *v1.ListJobsResponse, err error)

ListJobs lists jobs

func (*Service) Listen

func (srv *Service) Listen(req *v1.ListenRequest, ls v1.WerftService_ListenServer) error

Listen listens to logs

func (*Service) RegisterPrometheusMetrics

func (srv *Service) RegisterPrometheusMetrics(reg prometheus.Registerer)

RegisterPrometheusMetrics registers the service metrics on the registerer with MustRegister

func (*Service) RunJob

func (srv *Service) RunJob(ctx context.Context, name string, metadata v1.JobMetadata, cp ContentProvider, jobYAML []byte, canReplay bool, waitUntil time.Time) (status *v1.JobStatus, err error)

RunJob starts a build job from some context

func (*Service) Start

func (srv *Service) Start() error

Start sets up everything to run this werft instance, including executor config

func (*Service) StartFromPreviousJob

func (srv *Service) StartFromPreviousJob(ctx context.Context, req *v1.StartFromPreviousJobRequest) (*v1.StartJobResponse, error)

StartFromPreviousJob starts a new job based on an old one

func (*Service) StartGitHubJob

func (srv *Service) StartGitHubJob(ctx context.Context, req *v1.StartGitHubJobRequest) (resp *v1.StartJobResponse, err error)

StartGitHubJob starts a job on a Git context, possibly with a custom job.

func (*Service) StartLocalJob

func (srv *Service) StartLocalJob(inc v1.WerftService_StartLocalJobServer) error

StartLocalJob starts a job whoose content is uploaded

func (*Service) StopJob

func (srv *Service) StopJob(ctx context.Context, req *v1.StopJobRequest) (*v1.StopJobResponse, error)

StopJob stops a running job

func (*Service) Subscribe

func (srv *Service) Subscribe(req *v1.SubscribeRequest, resp v1.WerftService_SubscribeServer) (err error)

Subscribe listens to job updates

type UIService

type UIService struct {
	Github *github.Client
	Repos  []string
	// contains filtered or unexported fields
}

UIService implements api/v1/WerftUIServer

func NewUIService

func NewUIService(gh *github.Client, repos []string) (*UIService, error)

NewUIService produces a new UI service and initializes its repo list

func (*UIService) ListJobSpecs

func (uis *UIService) ListJobSpecs(req *v1.ListJobSpecsRequest, srv v1.WerftUI_ListJobSpecsServer) error

ListJobSpecs returns a list of jobs that can be started through the UI.

Jump to

Keyboard shortcuts

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