Documentation
      ¶
    
    
  
    
  
    Index ¶
- func GetBundleDir(args []string) (string, error)
 - func GetBundleDirFromArgs(args []string) (string, error)
 - func GetSpecFilePath(bundleDir string) string
 - func HasCreateSubcommand(args []string) bool
 - func IsBundleFlag(arg string) bool
 - func LoadFrom(reader io.Reader) (*specs.Spec, error)
 - type Runtime
 - type RuntimeMock
 - type Spec
 - type SpecMock
 - func (mock *SpecMock) Flush() error
 - func (mock *SpecMock) FlushCalls() []struct{}
 - func (mock *SpecMock) Load() (*specs.Spec, error)
 - func (mock *SpecMock) LoadCalls() []struct{}
 - func (mock *SpecMock) LookupEnv(s string) (string, bool)
 - func (mock *SpecMock) LookupEnvCalls() []struct{ ... }
 - func (mock *SpecMock) Modify(specModifier SpecModifier) error
 - func (mock *SpecMock) ModifyCalls() []struct{ ... }
 
- type SpecModifier
 - type State
 
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBundleDir ¶
GetBundleDir returns the bundle directory or default depending on the supplied command line arguments.
func GetBundleDirFromArgs ¶
GetBundleDirFromArgs checks the specified slice of strings (argv) for a 'bundle' flag as allowed by runc. The following are supported: --bundle{{SEP}}BUNDLE_PATH -bundle{{SEP}}BUNDLE_PATH -b{{SEP}}BUNDLE_PATH where {{SEP}} is either ' ' or '='
func GetSpecFilePath ¶
GetSpecFilePath returns the expected path to the OCI specification file for the given bundle directory.
func HasCreateSubcommand ¶
HasCreateSubcommand checks the supplied arguments for a 'create' subcommand
func IsBundleFlag ¶
IsBundleFlag is a helper function that checks wither the specified argument represents a bundle flag (--bundle or -b)
Types ¶
type Runtime ¶
Runtime is an interface for a runtime shim. The Exec method accepts a list of command line arguments, and returns an error / nil.
func NewLowLevelRuntime ¶
NewLowLevelRuntime creates a Runtime that wraps a low-level runtime executable. The executable specified is taken from the list of supplied candidates, with the first match present in the PATH being selected. A logger is also specified.
func NewModifyingRuntimeWrapper ¶ added in v1.13.0
func NewModifyingRuntimeWrapper(logger logger.Interface, runtime Runtime, spec Spec, modifier SpecModifier) Runtime
NewModifyingRuntimeWrapper creates a runtime wrapper that applies the specified modifier to the OCI specification before invoking the wrapped runtime. If the modifier is nil, the input runtime is returned.
type RuntimeMock ¶
type RuntimeMock struct {
	// ExecFunc mocks the Exec method.
	ExecFunc func(strings []string) error
	// StringFunc mocks the String method.
	StringFunc func() string
	// contains filtered or unexported fields
}
    RuntimeMock is a mock implementation of Runtime.
func TestSomethingThatUsesRuntime(t *testing.T) {
	// make and configure a mocked Runtime
	mockedRuntime := &RuntimeMock{
		ExecFunc: func(strings []string) error {
			panic("mock out the Exec method")
		},
		StringFunc: func() string {
			panic("mock out the String method")
		},
	}
	// use mockedRuntime in code that requires Runtime
	// and then make assertions.
}
func (*RuntimeMock) Exec ¶
func (mock *RuntimeMock) Exec(strings []string) error
Exec calls ExecFunc.
func (*RuntimeMock) ExecCalls ¶
func (mock *RuntimeMock) ExecCalls() []struct { Strings []string }
ExecCalls gets all the calls that were made to Exec. Check the length with:
len(mockedRuntime.ExecCalls())
func (*RuntimeMock) String ¶ added in v1.16.0
func (mock *RuntimeMock) String() string
String calls StringFunc.
func (*RuntimeMock) StringCalls ¶ added in v1.16.0
func (mock *RuntimeMock) StringCalls() []struct { }
StringCalls gets all the calls that were made to String. Check the length with:
len(mockedRuntime.StringCalls())
type Spec ¶
type Spec interface {
	Load() (*specs.Spec, error)
	Flush() error
	Modify(SpecModifier) error
	LookupEnv(string) (string, bool)
}
    Spec defines the operations to be performed on an OCI specification
func NewFileSpec ¶ added in v1.10.0
NewFileSpec 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.
func NewMemorySpec ¶ added in v1.10.0
func NewMemorySpec(spec *specs.Spec) Spec
NewMemorySpec creates a Spec instance from the specified OCI spec
type SpecMock ¶
type SpecMock struct {
	// FlushFunc mocks the Flush method.
	FlushFunc func() error
	// LoadFunc mocks the Load method.
	LoadFunc func() (*specs.Spec, error)
	// LookupEnvFunc mocks the LookupEnv method.
	LookupEnvFunc func(s string) (string, bool)
	// ModifyFunc mocks the Modify method.
	ModifyFunc func(specModifier SpecModifier) error
	// contains filtered or unexported fields
}
    SpecMock is a mock implementation of Spec.
func TestSomethingThatUsesSpec(t *testing.T) {
	// make and configure a mocked Spec
	mockedSpec := &SpecMock{
		FlushFunc: func() error {
			panic("mock out the Flush method")
		},
		LoadFunc: func() (*specs.Spec, error) {
			panic("mock out the Load method")
		},
		LookupEnvFunc: func(s string) (string, bool) {
			panic("mock out the LookupEnv method")
		},
		ModifyFunc: func(specModifier SpecModifier) error {
			panic("mock out the Modify method")
		},
	}
	// use mockedSpec in code that requires Spec
	// and then make assertions.
}
func (*SpecMock) FlushCalls ¶
func (mock *SpecMock) FlushCalls() []struct { }
FlushCalls gets all the calls that were made to Flush. Check the length with:
len(mockedSpec.FlushCalls())
func (*SpecMock) LoadCalls ¶
func (mock *SpecMock) LoadCalls() []struct { }
LoadCalls gets all the calls that were made to Load. Check the length with:
len(mockedSpec.LoadCalls())
func (*SpecMock) LookupEnvCalls ¶
LookupEnvCalls gets all the calls that were made to LookupEnv. Check the length with:
len(mockedSpec.LookupEnvCalls())
func (*SpecMock) Modify ¶
func (mock *SpecMock) Modify(specModifier SpecModifier) error
Modify calls ModifyFunc.
func (*SpecMock) ModifyCalls ¶
func (mock *SpecMock) ModifyCalls() []struct { SpecModifier SpecModifier }
ModifyCalls gets all the calls that were made to Modify. Check the length with:
len(mockedSpec.ModifyCalls())
type SpecModifier ¶
type SpecModifier interface {
	// Modify is a method that accepts a pointer to an OCI Spec and returns an
	// error. The intention is that the function would modify the spec in-place.
	Modify(*specs.Spec) error
}
    SpecModifier defines an interface for modifying a (raw) OCI spec
type State ¶ added in v1.10.0
type State specs.State
State stores an OCI container state. This includes the spec path and the environment
func LoadContainerState ¶ added in v1.10.0
LoadContainerState loads the container state from the specified filename. If the filename is empty or '-' the state is loaded from STDIN
func ReadContainerState ¶ added in v1.10.0
ReadContainerState reads the container state from the specified reader
func (*State) GetContainerRoot ¶ added in v1.10.0
GetContainerRoot returns the root for the container from the associated spec. If the spec is not yet loaded, it is loaded and cached.