werft

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 40 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 CompositeContentProvider added in v0.2.0

type CompositeContentProvider []ContentProvider

func (CompositeContentProvider) InitContainer added in v0.2.0

func (c CompositeContentProvider) InitContainer() ([]corev1.Container, error)

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.

func (CompositeContentProvider) Serve added in v0.2.0

func (c CompositeContentProvider) Serve(jobName string) error

Serve provides additional services required during initialization. This function is expected to return immediately.

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

	// GCOlderThan enables the garbage collector which collects all jobs and
	// logs older than the configured duration.
	GCOlderThan *executor.Duration `yaml:"gcOlderThan,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)

	// ListFiles lists all files in a directory. If path is not a directory
	// an error may be returned or just an empty list of paths. The paths returned
	// are all relative to the repo root.
	ListFiles(ctx context.Context, path string) (paths []string, err error)
}

FileProvider provides access to a single file

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 NoopRepositoryProvider added in v0.1.1

type NoopRepositoryProvider struct{}

NoopRepositoryProvider provides no access to no repository

func (NoopRepositoryProvider) ContentProvider added in v0.1.1

func (NoopRepositoryProvider) ContentProvider(ctx context.Context, repo *v1.Repository, paths ...string) (ContentProvider, error)

ContentProvider produces a content provider for a particular repo

func (NoopRepositoryProvider) FileProvider added in v0.1.1

FileProvider provides direct access to repository content

func (NoopRepositoryProvider) RemoteAnnotations added in v0.1.1

func (NoopRepositoryProvider) RemoteAnnotations(ctx context.Context, repo *v1.Repository) (annotations map[string]string, err error)

RemoteAnnotations extracts werft annotations form information associated with a particular commit, e.g. the commit message, PRs or merge requests. Implementors can expect the revision of the repo object to be set.

func (NoopRepositoryProvider) Resolve added in v0.1.1

Resolve resolves the repo's revision based on its ref(erence). If the revision is already set, this operation does nothing.

type RepositoryProvider added in v0.1.1

type RepositoryProvider interface {
	// Resolve resolves the repo's revision based on its ref(erence).
	// If the revision is already set, this operation does nothing.
	Resolve(ctx context.Context, repo *v1.Repository) error

	// RemoteAnnotations extracts werft annotations form information associated
	// with a particular commit, e.g. the commit message, PRs or merge requests.
	// Implementors can expect the revision of the repo object to be set.
	RemoteAnnotations(ctx context.Context, repo *v1.Repository) (annotations map[string]string, err error)

	// ContentProvider produces a content provider for a particular repo
	ContentProvider(ctx context.Context, repo *v1.Repository, path ...string) (ContentProvider, error)

	// FileProvider provides direct access to repository content
	FileProvider(ctx context.Context, repo *v1.Repository) (FileProvider, error)
}

RepositoryProvider provides access to a repository

type Service

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

	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) 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, spec v1.JobSpec, cp ContentProvider, jobYAML []byte, canReplay bool) (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) StartJob added in v0.1.1

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

StartJob starts a new job based on its specification.

func (*Service) StartJob2 added in v0.2.0

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

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 SideloadingContentProvider added in v0.1.1

type SideloadingContentProvider struct {
	TarStream  io.Reader
	Namespace  string
	Kubeconfig *rest.Config
	Clientset  kubernetes.Interface
}

SideloadingContentProvider first runs the delegate and then sideloads files

func (*SideloadingContentProvider) InitContainer added in v0.1.1

func (s *SideloadingContentProvider) InitContainer() ([]corev1.Container, error)

InitContainer adds the sideload init container

func (*SideloadingContentProvider) Serve added in v0.1.1

func (s *SideloadingContentProvider) Serve(jobName string) error

Serve serves the actual sideload

type UIService

type UIService struct {
	RepositoryProvider RepositoryProvider
	Repos              []string
	Readonly           bool
	// contains filtered or unexported fields
}

UIService implements api/v1/WerftUIServer

func NewUIService

func NewUIService(repoprov RepositoryProvider, repos []string, readonly bool, updateInterval time.Duration) (*UIService, error)

NewUIService produces a new UI service and initializes its repo list

func (*UIService) IsReadOnly added in v0.1.1

IsReadOnly returns true if the UI is readonly.

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