worker

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildOptions

type BuildOptions struct {
	StageFilter string
}

BuildOptions defines filtering options to control what parts of a build should actually be executed.

type Builder

type Builder interface {
	Definition() wharfyml.Definition
	Build(ctx context.Context) (Result, error)
}

Builder is the interface for running a Wharf build. A single Wharf build may contain any number of stages, which in turn may contain any number of steps. All stages will be run in sequence.

func New

func New(ctx context.Context, stageRunFactory StageRunnerFactory, def wharfyml.Definition, opts BuildOptions) (Builder, error)

New returns a new Builder implementation that uses the provided StageRunner to run all build stages in series.

func NewK8s

NewK8s is a helper function that creates a new builder using the NewK8sStepRunnerFactory.

type DryRun

type DryRun byte

DryRun is an enum of dry-run settings.

const (
	// DryRunNone disables dry-run. The build will be performed as usual.
	DryRunNone DryRun = iota
	// DryRunClient only logs what would be run, without contacting Kubernetes.
	DryRunClient
	// DryRunServer submits server-side dry-run requests to Kubernetes.
	DryRunServer
)

type K8sRunnerOptions

type K8sRunnerOptions struct {
	BuildOptions
	Config        *config.Config
	RestConfig    *rest.Config
	ResultStore   resultstore.Store
	TarStore      tarstore.Store
	VarSource     varsub.Source
	SkipGitIgnore bool
	CurrentDir    string
	DryRun        DryRun
}

K8sRunnerOptions is a struct of options for a Kubernetes step runner.

type Result

type Result struct {
	Status   workermodel.Status // execution status of the entire build
	Options  BuildOptions       // options used when running the build
	Stages   []StageResult      // execution results for each stage
	Duration time.Duration      // execution duration of the entire build
}

Result is a Wharf build result with the overall status of all stages were executed, the induvidual stage results, as well as the duration of the entire Wharf build.

type StageResult

type StageResult struct {
	Name     string             // name of the stage
	Status   workermodel.Status // execution status of the stage
	Steps    []StepResult       // execution results for each step
	Duration time.Duration      // execution duration of the stage
}

StageResult is a Wharf build stage result with the overall status of the steps that was executed for the stage, as well as the duration of the Wharf build stage.

type StageRunner

type StageRunner interface {
	Stage() wharfyml.Stage
	RunStage(ctx context.Context) StageResult
}

StageRunner is the interface for running a Wharf build stage. A single Wharf build stage may contain any number of steps which will all be run in parallel.

type StageRunnerFactory

type StageRunnerFactory interface {
	NewStageRunner(ctx context.Context, stage wharfyml.Stage, stepIDOffset uint64) (StageRunner, error)
}

StageRunnerFactory creates a new StageRunner for a given stage.

func NewK8sStageRunnerFactory

func NewK8sStageRunnerFactory(opts K8sRunnerOptions) (StageRunnerFactory, error)

NewK8sStageRunnerFactory is a helper function that creates a new stage runner factory using the NewK8sStepRunnerFactory.

func NewStageRunnerFactory

func NewStageRunnerFactory(stepRunFactory StepRunnerFactory) (StageRunnerFactory, error)

NewStageRunnerFactory returns a new StageRunner that uses the provided StepRunner to run the steps in parallel.

type StepResult

type StepResult struct {
	Name     string             // name of the step
	Status   workermodel.Status // execution status of the step
	Type     string             // type of Wharf build step, eg. "container" or "docker"
	Error    error              // error message from the execution, if any
	Duration time.Duration      // execution duration of the step
}

StepResult is a Wharf build step result with the status of the step execution as well as the duration of the Wharf build step.

type StepRunner

type StepRunner interface {
	Step() wharfyml.Step
	RunStep(ctx context.Context) StepResult
}

StepRunner is the interface for running a Wharf build step. Steps are the smallest unit of work in Wharf, and each step represents a single Kubernetes pod or Docker container.

type StepRunnerFactory

type StepRunnerFactory interface {
	NewStepRunner(ctx context.Context, step wharfyml.Step, stepID uint64) (StepRunner, error)
}

StepRunnerFactory creates a new StepRunner for a given step.

func NewK8sStepRunnerFactory

func NewK8sStepRunnerFactory(opts K8sRunnerOptions) (StepRunnerFactory, error)

NewK8sStepRunnerFactory returns a new step runner factory that creates step runners with implementation that targets Kubernetes using a specific Kubernetes namespace and REST config.

Directories

Path Synopsis
Package workerclient provides a way to communicate with a Wharf worker server.
Package workerclient provides a way to communicate with a Wharf worker server.
Package workerserver provides a way for a worker to set up servers for both gRPC and HTTP communication.
Package workerserver provides a way for a worker to set up servers for both gRPC and HTTP communication.
docs
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag

Jump to

Keyboard shortcuts

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