run

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultRuntime is the runtime to use when not specified.
	DefaultRuntime = "runc"
	// NameTotalLengthMax is the maximum total number of characters in a
	// repository name.
	NameTotalLengthMax = 255
	// DefaultTag defines the default tag used when performing images related
	// actions and no tag or digest is specified.
	DefaultTag = "latest"
	// DefaultHostname is the default built-in hostname
	DefaultHostname = "docker.io"
	// LegacyDefaultHostname is automatically converted to DefaultHostname
	LegacyDefaultHostname = "index.docker.io"
	// DefaultRepoPrefix is the prefix used for default repositories in default
	// host.
	DefaultRepoPrefix = "library/"
)

Variables

View Source
var (
	// ErrReferenceInvalidFormat represents an error while trying to parse a
	// string as a reference.
	ErrReferenceInvalidFormat = errors.New("invalid reference format")
	// ErrTagInvalidFormat represents an error while trying to parse a string as a
	// tag.
	ErrTagInvalidFormat = errors.New("invalid tag format")
	// ErrDigestInvalidFormat represents an error while trying to parse a string
	// as a tag.
	ErrDigestInvalidFormat = errors.New("invalid digest format")
	// ErrNameEmpty is returned for empty, invalid repository names.
	ErrNameEmpty = errors.New("repository name must have at least one component")
	// ErrNameTooLong is returned when a repository name is longer than
	// NameTotalLengthMax.
	ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax)
)
View Source
var (

	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
	TagRegexp = match(`[\w][\w.-]{0,127}`)

	// DigestRegexp matches valid digests.
	DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)

	// RuntimeRegexp
	RuntimeRexp = expression(
		optional(capture(alphaRegexp), literal(`://`)))

	// NameRegexp is the format for the name component of references. The
	// regexp has capturing groups for the hostname and name part omitting
	// the separating forward slash from either.
	NameRegexp = expression(
		optional(hostnameRegexp, literal(`/`)),
		nameComponentRegexp,
		optional(repeated(literal(`/`), nameComponentRegexp)))

	// ReferenceRegexp is the full supported format of a reference. The regexp
	// is anchored and has capturing groups for name, tag, and digest
	// components.
	ReferenceRegexp = anchored(capture(RuntimeRexp),
		capture(NameRegexp),
		optional(literal(":"), capture(TagRegexp)),
		optional(literal("@"), capture(DigestRegexp)))
)

Functions

func PullImage

func PullImage(image, cacheDir string) (v1.Image, error)

PullImage downloads an image

func UnpackImage

func UnpackImage(image v1.Image, cacheDir, outDir string, allowOverride bool) error

UnpackImage takes a container image and writes its filesystem to outDir

Types

type Bridge

type Bridge struct {
	Name      string
	Interface string
	Subnet    string
	CacheDir  string
	// contains filtered or unexported fields
}

func (*Bridge) Create

func (b *Bridge) Create(s *specs.State) (net.IP, error)

Create a veth pair with the bridge for the container

func (*Bridge) Init

func (b *Bridge) Init(dryRun bool) error

Init prepares netns

type Image

type Image struct {
	// Runtime is the normalized name of the runtime service, e.g. "docker"
	Runtime string
	// Name is the normalized repository name, like "ubuntu".
	Name string
	// String is the full reference, like "ubuntu@sha256:abcdef..."
	String string
	// FullName is the full repository name with hostname, like "docker.io/library/ubuntu"
	FullName string
	// Hostname is the hostname for the reference, like "docker.io"
	Hostname string
	// RemoteName is the the repository component of the full name, like "library/ubuntu"
	RemoteName string
	// Tag is the tag of the image, e.g. "latest"
	Tag string
}

Image is an object with a full name

type Input

type Input struct {
	Name        string   `yaml:"name"`
	Source      string   `yaml:"source"`
	Destination string   `yaml:"destination"`
	Options     []string `yaml:"options"`
}

type Output

type Output struct {
	Name string `yaml:"name"`
	Path string `yaml:"path"`
}

type Run

type Run struct {
	Name         string   `yaml:"name"`
	Image        string   `yaml:"image"`
	Cores        int      `yaml:"cores"`
	Devices      []string `yaml:"devices"`
	Cmd          string   `yaml:"cmd"`
	Path         string   `yaml:"path"`
	Capabilities []string
	// contains filtered or unexported fields
}

type Runner

type Runner struct {
	Config *RunnerConfig
	Bridge *Bridge
	// contains filtered or unexported fields
}

func NewRunner

func NewRunner(cfg *RunnerConfig, bridge *Bridge, dryRun bool) (*Runner, error)

NewRunner returns the name of the

func (*Runner) Destroy

func (r *Runner) Destroy() error

Destroy the runc container

func (*Runner) Init

func (r *Runner) Init(in *[]Input, out *[]Output, dryRun bool) error

func (*Runner) Run

func (r *Runner) Run() (int, time.Duration, error)

Run the runc container

type RunnerConfig

type RunnerConfig struct {
	Log           *log.Logger
	ResultsDir    string
	CacheDir      string
	Name          string
	Image         string
	CoreIds       []int
	Devices       []string
	Path          string
	Cmd           string
	AllowOverride bool
	Inputs        *[]Input
	Outputs       *[]Output
	Env           []string
	Capabilities  []string
}

Jump to

Keyboard shortcuts

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