runtime

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: Apache-2.0 Imports: 10 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{"VELA_LOG_FORMAT", "RUNTIME_LOG_FORMAT"},
		FilePath: "/vela/runtime/log_format",
		Name:     "runtime.log.format",
		Usage:    "format of logs to output",
		Value:    "json",
	},
	&cli.StringFlag{
		EnvVars:  []string{"VELA_LOG_LEVEL", "RUNTIME_LOG_LEVEL"},
		FilePath: "/vela/runtime/log_level",
		Name:     "runtime.log.level",
		Usage:    "level of logs to output",
		Value:    "info",
	},

	&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

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 {

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

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

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

type Setup struct {

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

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