runtime

package
v0.13.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package runtime provides the ability for Vela to integrate with different supported Runtime environments.

Currently the following runtimes are supported:

* Docker - https://docker.io/ * Kubernetes - https://kubernetes.io/

Usage:

import "github.com/go-vela/worker/runtime"

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_DRIVER", "RUNTIME_DRIVER"},
		FilePath: "/vela/runtime/driver",
		Name:     "runtime.driver",
		Usage:    "driver to be used for the runtime",
		Value:    constants.DriverDocker,
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_CONFIG", "RUNTIME_CONFIG"},
		FilePath: "/vela/runtime/config",
		Name:     "runtime.config",
		Usage:    "path to configuration file for the runtime",
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_RUNTIME_NAMESPACE", "RUNTIME_NAMESPACE"},
		FilePath: "/vela/runtime/namespace",
		Name:     "runtime.namespace",
		Usage:    "namespace to use for the runtime (only used by kubernetes)",
	},
	&cli.StringSliceFlag{
		EnvVars:  []string{"VELA_RUNTIME_PRIVILEGED_IMAGES", "RUNTIME_PRIVILEGED_IMAGES"},
		FilePath: "/vela/runtime/privileged_images",
		Name:     "runtime.privileged-images",
		Usage:    "list of images allowed to run in privileged mode for the runtime",
		Value:    cli.NewStringSlice("target/vela-docker"),
	},
	&cli.StringSliceFlag{
		EnvVars:  []string{"VELA_RUNTIME_VOLUMES", "RUNTIME_VOLUMES"},
		FilePath: "/vela/runtime/volumes",
		Name:     "runtime.volumes",
		Usage:    "list of host volumes to mount for the runtime",
	},
}

Flags represents all supported command line interface (CLI) flags for the runtime.

https://pkg.go.dev/github.com/urfave/cli?tab=doc#Flag

Functions

func WithContext added in v0.11.0

func WithContext(c context.Context, e Engine) context.Context

WithContext inserts the runtime Engine into the context.Context.

func WithGinContext added in v0.11.0

func WithGinContext(c *gin.Context, e Engine)

WithGinContext inserts the runtime Engine into the gin.Context.

Types

type Engine

type Engine interface {

	// Driver defines a function that outputs
	// the configured runtime driver.
	Driver() string

	// InspectBuild defines a function that
	// displays details about the build for the init step.
	InspectBuild(ctx context.Context, b *pipeline.Build) ([]byte, error)
	// SetupBuild defines a function that
	// prepares the pipeline build.
	SetupBuild(context.Context, *pipeline.Build) error
	// AssembleBuild defines a function that
	// finalizes pipeline build setup.
	AssembleBuild(context.Context, *pipeline.Build) error
	// RemoveBuild defines a function that deletes
	// (kill, remove) the pipeline build metadata.
	RemoveBuild(context.Context, *pipeline.Build) error

	// InspectContainer defines a function that inspects
	// the pipeline container.
	InspectContainer(context.Context, *pipeline.Container) error
	// RemoveContainer defines a function that deletes
	// (kill, remove) the pipeline container.
	RemoveContainer(context.Context, *pipeline.Container) error
	// RunContainer defines a function that creates
	// and starts the pipeline container.
	RunContainer(context.Context, *pipeline.Container, *pipeline.Build) error
	// SetupContainer defines a function that prepares
	// the image for the pipeline container.
	SetupContainer(context.Context, *pipeline.Container) error
	// TailContainer defines a function that captures
	// the logs on the pipeline container.
	TailContainer(context.Context, *pipeline.Container) (io.ReadCloser, error)
	// WaitContainer defines a function that blocks
	// until the pipeline container completes.
	WaitContainer(context.Context, *pipeline.Container) error

	// CreateImage defines a function that
	// creates the pipeline container image.
	CreateImage(context.Context, *pipeline.Container) error
	// InspectImage defines a function that
	// inspects the pipeline container image.
	InspectImage(context.Context, *pipeline.Container) ([]byte, error)

	// CreateNetwork defines a function that
	// creates the pipeline network.
	CreateNetwork(context.Context, *pipeline.Build) error
	// InspectNetwork defines a function that
	// inspects the pipeline network.
	InspectNetwork(context.Context, *pipeline.Build) ([]byte, error)
	// RemoveNetwork defines a function that
	// deletes the pipeline network.
	RemoveNetwork(context.Context, *pipeline.Build) error

	// CreateVolume defines a function that
	// creates the pipeline volume.
	CreateVolume(context.Context, *pipeline.Build) error
	// InspectVolume defines a function that
	// inspects the pipeline volume.
	InspectVolume(context.Context, *pipeline.Build) ([]byte, error)
	// RemoveVolume defines a function that
	// deletes the pipeline volume.
	RemoveVolume(context.Context, *pipeline.Build) error
}

Engine represents the interface for Vela integrating with the different supported Runtime environments.

func FromContext

func FromContext(c context.Context) Engine

FromContext retrieves the runtime Engine from the context.Context.

func FromGinContext added in v0.11.0

func FromGinContext(c *gin.Context) Engine

FromGinContext retrieves the runtime Engine from the gin.Context.

func New added in v0.11.0

func New(s *Setup) (Engine, error)

nolint: godot // ignore period at end for comment ending in a list

New creates and returns a Vela engine capable of integrating with the configured runtime.

Currently the following runtimes are supported:

* docker * kubernetes

type Setup added in v0.11.0

type Setup struct {
	// https://pkg.go.dev/github.com/sirupsen/logrus#Entry
	Logger *logrus.Entry

	// specifies the driver to use for the runtime client
	Driver string
	// specifies the path to a configuration file to use for the runtime client
	ConfigFile string
	// specifies a list of host volumes to use for the runtime client
	HostVolumes []string
	// specifies the namespace to use for the runtime client (only used by kubernetes)
	Namespace string
	// specifies a list of privileged images to use for the runtime client
	PrivilegedImages []string
}

Setup represents the configuration necessary for creating a Vela engine capable of integrating with a configured runtime environment.

func (*Setup) Docker added in v0.11.0

func (s *Setup) Docker() (Engine, error)

Docker creates and returns a Vela engine capable of integrating with a Docker runtime environment.

func (*Setup) Kubernetes added in v0.11.0

func (s *Setup) Kubernetes() (Engine, error)

Kubernetes creates and returns a Vela engine capable of integrating with a Kubernetes runtime environment.

func (*Setup) Validate added in v0.11.0

func (s *Setup) Validate() error

Validate verifies the necessary fields for the provided configuration are populated correctly.

Directories

Path Synopsis
Package docker provides the ability for Vela to integrate with Docker as a runtime environment.
Package docker provides the ability for Vela to integrate with Docker as a runtime environment.
Package kubernetes provides the ability for Vela to integrate with Kubernetes as a runtime environment.
Package kubernetes provides the ability for Vela to integrate with Kubernetes as a runtime environment.

Jump to

Keyboard shortcuts

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