oci

package
v1.6.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockExecRuntime

type MockExecRuntime struct {
	SyscallExecRuntime
	// contains filtered or unexported fields
}

MockExecRuntime wraps a SyscallExecRuntime, intercepting the exec call for testing

func WithMockExec

func WithMockExec(e SyscallExecRuntime, execResult error) *MockExecRuntime

WithMockExec wraps a specified SyscallExecRuntime with a mocked exec function for testing

type MockSpec

type MockSpec struct {
	*oci.Spec
	MockLoad   mockFunc
	MockFlush  mockFunc
	MockModify mockFunc
}

MockSpec provides a simple mock for an OCI spec to be used in testing. It also implements the SpecModifier interface.

func NewMockSpec

func NewMockSpec(spec *oci.Spec, flushResult error, modifyResult error) *MockSpec

NewMockSpec constructs a MockSpec to be used in testing as a Spec

func (*MockSpec) Flush

func (s *MockSpec) Flush() error

Flush invokes the mocked Load function to return the predefined error / result

func (*MockSpec) Load

func (s *MockSpec) Load() error

Load invokes the mocked Load function to return the predefined error / result

func (*MockSpec) Modify

func (s *MockSpec) Modify(f SpecModifier) error

Modify applies the specified SpecModifier to the spec and invokes the mocked modify function to return the predefined error / result.

type Runtime

type Runtime interface {
	Exec([]string) error
}

Runtime is an interface for a runtime shim. The Exec method accepts a list of command line arguments, and returns an error / nil.

func NewSyscallExecRuntime

func NewSyscallExecRuntime(path string) (Runtime, error)

NewSyscallExecRuntime creates a SyscallExecRuntime for the specified path with the standard logger

func NewSyscallExecRuntimeWithLogger

func NewSyscallExecRuntimeWithLogger(logger *log.Logger, path string) (Runtime, error)

NewSyscallExecRuntimeWithLogger creates a SyscallExecRuntime for the specified logger and path

type Spec

type Spec interface {
	Load() error
	Flush() error
	Modify(SpecModifier) error
}

Spec defines the operations to be performed on an OCI specification

func NewSpecFromFile

func NewSpecFromFile(filepath string) Spec

NewSpecFromFile creates an object that encapsulates a file-backed OCI spec. This can be used to read from the file, modify the spec, and write to the same file.

type SpecModifier

type SpecModifier func(*oci.Spec) error

SpecModifier is a function that accepts a pointer to an OCI Srec and returns an error. The intention is that the function would modify the spec in-place.

type SyscallExecRuntime

type SyscallExecRuntime struct {
	// contains filtered or unexported fields
}

SyscallExecRuntime wraps the path that a binary and defines the semanitcs for how to exec into it. This can be used to wrap an OCI-compliant low-level runtime binary, allowing it to be used through the Runtime internface.

func (SyscallExecRuntime) Exec

func (s SyscallExecRuntime) Exec(args []string) error

Exec exces into the binary at the path from the SyscallExecRuntime struct, passing it the supplied arguments after ensuring that the first argument is the path of the target binary.

Jump to

Keyboard shortcuts

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