runtime

package
v0.7.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

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/pkg-runtime/runtime"

Index

Constants

This section is empty.

Variables

View Source
var Flags = []cli.Flag{

	&cli.StringFlag{
		EnvVars: []string{"RUNTIME_LOG_LEVEL", "VELA_LOG_LEVEL", "LOG_LEVEL"},
		Name:    "runtime.log.level",
		Usage:   "set log level - options: (trace|debug|info|warn|error|fatal|panic)",
		Value:   "info",
	},

	&cli.StringFlag{
		EnvVars: []string{"VELA_RUNTIME_DRIVER", "RUNTIME_DRIVER"},
		Name:    "runtime.driver",
		Usage:   "name of runtime driver to use",
		Value:   constants.DriverDocker,
	},
	&cli.StringFlag{
		EnvVars: []string{"VELA_RUNTIME_CONFIG", "RUNTIME_CONFIG"},
		Name:    "runtime.config",
		Usage:   "path to runtime configuration file",
	},
	&cli.StringFlag{
		EnvVars: []string{"VELA_RUNTIME_NAMESPACE", "RUNTIME_NAMESPACE"},
		Name:    "runtime.namespace",
		Usage:   "name of namespace for runtime configuration (kubernetes runtime only)",
	},
	&cli.StringSliceFlag{
		EnvVars: []string{"VELA_RUNTIME_VOLUMES", "RUNTIME_VOLUMES"},
		Name:    "runtime.volumes",
		Usage:   "set of volumes to mount into the runtime",
	},
	&cli.StringSliceFlag{
		EnvVars: []string{"VELA_ALLOWED_PRIVILEGED_IMAGES", "RUNTIME_VOLUMES"},
		Name:    "runtime.allowed-privileged-images",
		Usage:   "set of images that are allowed to run in privileged mode",
	},
}

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

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

WithContext inserts the runtime Engine into the context.Context.

func WithGinContext

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

WithGinContext inserts the runtime Engine into the gin.Context.

Types

type Engine

type Engine interface {

	// 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

func FromGinContext(c *gin.Context) Engine

FromGinContext retrieves the runtime Engine from the gin.Context.

func New

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

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

Currently the following runtimes are supported:

* docker * kubernetes

type Setup

type Setup struct {
	Driver           string
	Config           string
	Namespace        string
	Volumes          []string
	PrivilegedImages []string
}

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

func (*Setup) Docker

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

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

func (*Setup) Kubernetes

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

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

func (*Setup) Validate

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