oci

package
v0.0.0-...-e90dc35 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2018 License: Apache-2.0, Apache-2.0, Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// StateCreated represents a container that has been created and is
	// ready to be run.
	StateCreated = "created"

	// StateRunning represents a container that's currently running.
	StateRunning = "running"

	// StateStopped represents a container that has been stopped.
	StateStopped = "stopped"

	// StatePaused represents a container that has been paused.
	StatePaused = "paused"
)

Variables

View Source
var (
	// ErrNoLinux is an error for missing Linux sections in the OCI configuration file.
	ErrNoLinux = errors.New("missing Linux section")

	// CRIContainerTypeKeyList lists all the CRI keys that could define
	// the container type from annotations in the config.json.
	CRIContainerTypeKeyList = []string{criContainerdAnnotations.ContainerType, crioAnnotations.ContainerType, dockershimAnnotations.ContainerTypeLabelKey}

	// CRISandboxNameKeyList lists all the CRI keys that could define
	// the sandbox ID (sandbox ID) from annotations in the config.json.
	CRISandboxNameKeyList = []string{criContainerdAnnotations.SandboxID, crioAnnotations.SandboxID, dockershimAnnotations.SandboxIDLabelKey}

	// CRIContainerTypeList lists all the maps from CRI ContainerTypes annotations
	// to a virtcontainers ContainerType.
	CRIContainerTypeList = []annotationContainerType{
		{crioAnnotations.ContainerTypeSandbox, vc.PodSandbox},
		{crioAnnotations.ContainerTypeContainer, vc.PodContainer},
		{criContainerdAnnotations.ContainerTypeSandbox, vc.PodSandbox},
		{criContainerdAnnotations.ContainerTypeContainer, vc.PodContainer},
		{dockershimAnnotations.ContainerTypeLabelSandbox, vc.PodSandbox},
		{dockershimAnnotations.ContainerTypeLabelContainer, vc.PodContainer},
	}
)

Functions

func ContainerCapabilities

func ContainerCapabilities(s CompatOCISpec) (vc.LinuxCapabilities, error)

ContainerCapabilities return a LinuxCapabilities for virtcontainer

func ContainerConfig

func ContainerConfig(ocispec CompatOCISpec, bundlePath, cid, console string, detach bool) (vc.ContainerConfig, error)

ContainerConfig converts an OCI compatible runtime configuration file to a virtcontainers container configuration structure.

func EnvVars

func EnvVars(envs []string) ([]vc.EnvVar, error)

EnvVars converts an OCI process environment variables slice into a virtcontainers EnvVar slice.

func GetContainerType

func GetContainerType(annotations map[string]string) (vc.ContainerType, error)

GetContainerType determines which type of container matches the annotations table provided.

func SandboxConfig

func SandboxConfig(ocispec CompatOCISpec, runtime RuntimeConfig, bundlePath, cid, console string, detach, systemdCgroup bool) (vc.SandboxConfig, error)

SandboxConfig converts an OCI compatible runtime configuration file to a virtcontainers sandbox configuration structure.

func SetLogger

func SetLogger(ctx context.Context, logger *logrus.Entry)

SetLogger sets the logger for oci package.

func StateToOCIState

func StateToOCIState(state vc.State) string

StateToOCIState translates a virtcontainers container state into an OCI one.

func StatusToOCIState

func StatusToOCIState(status vc.ContainerStatus) spec.State

StatusToOCIState translates a virtcontainers container status into an OCI state.

Types

type CompatOCIProcess

type CompatOCIProcess struct {
	spec.Process
	Capabilities interface{} `json:"capabilities,omitempty" platform:"linux"`
}

CompatOCIProcess is a structure inheriting from spec.Process defined in runtime-spec/specs-go package. The goal is to be compatible with both v1.0.0-rc4 and v1.0.0-rc5 since the latter introduced a change about the type of the Capabilities field. Refer to: https://github.com/opencontainers/runtime-spec/commit/37391fb

type CompatOCISpec

type CompatOCISpec struct {
	spec.Spec
	Process *CompatOCIProcess `json:"process,omitempty"`
}

CompatOCISpec is a structure inheriting from spec.Spec defined in runtime-spec/specs-go package. It relies on the CompatOCIProcess structure declared above, in order to be compatible with both v1.0.0-rc4 and v1.0.0-rc5. Refer to: https://github.com/opencontainers/runtime-spec/commit/37391fb

func GetOCIConfig

func GetOCIConfig(status vc.ContainerStatus) (CompatOCISpec, error)

GetOCIConfig returns an OCI spec configuration from the annotation stored into the container status.

func ParseConfigJSON

func ParseConfigJSON(bundlePath string) (CompatOCISpec, error)

ParseConfigJSON unmarshals the config.json file.

func (*CompatOCISpec) ContainerType

func (spec *CompatOCISpec) ContainerType() (vc.ContainerType, error)

ContainerType returns the type of container and if the container type was found from CRI servers annotations.

func (*CompatOCISpec) SandboxID

func (spec *CompatOCISpec) SandboxID() (string, error)

SandboxID determines the sandbox ID related to an OCI configuration. This function is expected to be called only when the container type is "PodContainer".

type FactoryConfig

type FactoryConfig struct {
	// Template enables VM templating support in VM factory.
	Template bool
}

FactoryConfig is a structure to set the VM factory configuration.

type RuntimeConfig

type RuntimeConfig struct {
	HypervisorType   vc.HypervisorType
	HypervisorConfig vc.HypervisorConfig

	NetmonConfig vc.NetmonConfig

	AgentType   vc.AgentType
	AgentConfig interface{}

	ProxyType   vc.ProxyType
	ProxyConfig vc.ProxyConfig

	ShimType   vc.ShimType
	ShimConfig interface{}

	Console string

	//Determines how the VM should be connected to the
	//the container network interface
	InterNetworkModel vc.NetInterworkingModel
	FactoryConfig     FactoryConfig
	Debug             bool

	//Determines if create a netns for hypervisor process
	DisableNewNetNs bool
}

RuntimeConfig aggregates all runtime specific settings

func (*RuntimeConfig) AddKernelParam

func (config *RuntimeConfig) AddKernelParam(p vc.Param) error

AddKernelParam allows the addition of new kernel parameters to an existing hypervisor configuration stored inside the current runtime configuration.

Jump to

Keyboard shortcuts

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