oci

package
v0.0.0-...-6ac1958 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2018 License: Apache-2.0, Apache-2.0, Apache-2.0 Imports: 14 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"
)

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 (pod 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 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 PodConfig

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

PodConfig converts an OCI compatible runtime configuration file to a virtcontainers pod configuration structure.

func SetLogger

func SetLogger(logger logrus.FieldLogger)

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

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

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

type RuntimeConfig

type RuntimeConfig struct {
	VMConfig vc.Resources

	HypervisorType   vc.HypervisorType
	HypervisorConfig vc.HypervisorConfig

	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
}

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