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
- type Runtime
- type RuntimeMock
- type Spec
- type SpecMock
- func (mock *SpecMock) Flush() error
- func (mock *SpecMock) FlushCalls() []struct{}
- func (mock *SpecMock) Load() 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
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.
func NewLowLevelRuntimeWithLogger ¶
NewLowLevelRuntimeWithLogger creates a Runtime as with NewLowLevelRuntime using the specified logger.
func NewRuntimeForPath ¶
NewRuntimeForPath creates a Runtime for the specified path with the standard logger
type RuntimeMock ¶
type RuntimeMock struct { // ExecFunc mocks the Exec method. ExecFunc func(strings []string) error // 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") }, } // 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())
type Spec ¶
type Spec interface { Load() error Flush() error Modify(SpecModifier) error LookupEnv(string) (string, bool) }
Spec defines the operations to be performed on an OCI specification
func NewSpecFromArgs ¶
NewSpecFromArgs creates fileSpec based on the command line arguments passed to the application
func NewSpecFromFile ¶
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 SpecMock ¶
type SpecMock struct { // FlushFunc mocks the Flush method. FlushFunc func() error // LoadFunc mocks the Load method. LoadFunc func() 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() 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 ¶
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.