Documentation ¶
Index ¶
- Constants
- func FakeLoopDeviceSnapshotsStatus(fs types.FS, rootDir string, snapsCount int) error
- type FakeBootloader
- func (f *FakeBootloader) DoEFIEntries(_, _ string) error
- func (f *FakeBootloader) Install(_, _ string) error
- func (f *FakeBootloader) InstallConfig(_, _ string) error
- func (f *FakeBootloader) InstallEFI(_, _ string) error
- func (f *FakeBootloader) InstallEFIBinaries(_, _, _ string) error
- func (f *FakeBootloader) SetDefaultEntry(_, _, _ string) error
- func (f *FakeBootloader) SetPersistentVariables(_ string, _ map[string]string) error
- type FakeCloudInitRunner
- type FakeHTTPClient
- type FakeImageExtractor
- type FakeMounter
- type FakeRunner
- func (r *FakeRunner) ClearCmds()
- func (r FakeRunner) CmdsMatch(cmdList [][]string) error
- func (r *FakeRunner) CommandExists(command string) bool
- func (r FakeRunner) GetCmds() [][]string
- func (r FakeRunner) GetLogger() types.Logger
- func (r FakeRunner) IncludesCmds(cmdList [][]string) error
- func (r *FakeRunner) InitCmd(command string, args ...string) *exec.Cmd
- func (r FakeRunner) MatchMilestones(cmdList [][]string) error
- func (r *FakeRunner) Run(command string, args ...string) ([]byte, error)
- func (r *FakeRunner) RunCmd(_ *exec.Cmd) ([]byte, error)
- func (r *FakeRunner) SetLogger(logger types.Logger)
- type FakeSyscall
- type GhwMock
- func (g *GhwMock) AddDisk(disk block.Disk)
- func (g *GhwMock) AddPartitionToDisk(diskName string, partition *block.Partition)
- func (g *GhwMock) Clean()
- func (g *GhwMock) CreateDevices()
- func (g *GhwMock) RemoveDisk(disk string)
- func (g *GhwMock) RemovePartitionFromDisk(diskName string, partitionName string)
- type LiveBootLoaderMock
- type MockEFIVariables
- func (m MockEFIVariables) DelVariable(_ efi.GUID, _ string) error
- func (m MockEFIVariables) GetVariable(guid efi.GUID, name string) (data []byte, attrs efi.VariableAttributes, err error)
- func (m MockEFIVariables) JSON() ([]byte, error)
- func (m MockEFIVariables) ListVariables() (out []efi.VariableDescriptor, err error)
- func (m MockEFIVariables) NewFileDevicePath(fpath string, _ efi_linux.FilePathToDevicePathMode) (efi.DevicePath, error)
- func (m MockEFIVariables) ReadLoadOption(_ io.Reader) (out *efi.LoadOption, err error)
- func (m MockEFIVariables) SetVariable(guid efi.GUID, name string, data []byte, attrs efi.VariableAttributes) error
- func (m *MockEFIVariables) WithLoadOptionError(err error) *MockEFIVariables
Constants ¶
const FakeDigest = "fakeDigest"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FakeBootloader ¶
type FakeBootloader struct { ErrorInstall bool ErrorInstallConfig bool ErrorDoEFIEntries bool ErrorInstallEFI bool ErrorInstallEFIBinaries bool ErrorSetPersistentVariables bool ErrorSetDefaultEntry bool }
func (*FakeBootloader) DoEFIEntries ¶
func (f *FakeBootloader) DoEFIEntries(_, _ string) error
func (*FakeBootloader) Install ¶
func (f *FakeBootloader) Install(_, _ string) error
func (*FakeBootloader) InstallConfig ¶
func (f *FakeBootloader) InstallConfig(_, _ string) error
func (*FakeBootloader) InstallEFI ¶
func (f *FakeBootloader) InstallEFI(_, _ string) error
func (*FakeBootloader) InstallEFIBinaries ¶
func (f *FakeBootloader) InstallEFIBinaries(_, _, _ string) error
func (*FakeBootloader) SetDefaultEntry ¶
func (f *FakeBootloader) SetDefaultEntry(_, _, _ string) error
func (*FakeBootloader) SetPersistentVariables ¶
func (f *FakeBootloader) SetPersistentVariables(_ string, _ map[string]string) error
type FakeCloudInitRunner ¶
type FakeCloudInitRunner struct { ExecStages []string Error bool RenderErr bool // contains filtered or unexported fields }
func (*FakeCloudInitRunner) CloudInitFileRender ¶
func (ci *FakeCloudInitRunner) CloudInitFileRender(_ string, _ *schema.YipConfig) error
func (*FakeCloudInitRunner) GetStageArgs ¶
func (ci *FakeCloudInitRunner) GetStageArgs(stage string) []string
func (*FakeCloudInitRunner) Run ¶
func (ci *FakeCloudInitRunner) Run(stage string, args ...string) error
func (*FakeCloudInitRunner) SetModifier ¶
func (ci *FakeCloudInitRunner) SetModifier(_ schema.Modifier)
type FakeHTTPClient ¶
FakeHTTPClient is an implementation of HTTPClient interface used for testing It stores Get calls into ClientCalls for easy checking of what was called
func (*FakeHTTPClient) GetURL ¶
GetURL will return a FakeHttpBody and store the url call into ClientCalls
func (*FakeHTTPClient) WasGetCalledWith ¶
func (m *FakeHTTPClient) WasGetCalledWith(url string) bool
WasGetCalledWith is a helper method to confirm that the client wazs called with the give url
type FakeImageExtractor ¶
type FakeImageExtractor struct { Logger types.Logger SideEffect func(imageRef, destination, platformRef string, local bool, verify bool) (string, error) }
func NewFakeImageExtractor ¶
func NewFakeImageExtractor(logger types.Logger) *FakeImageExtractor
func (FakeImageExtractor) ExtractImage ¶
type FakeMounter ¶
FakeMounter is a fake mounter for tests that can error out.
func NewFakeMounter ¶
func NewFakeMounter() *FakeMounter
NewFakeMounter returns an FakeMounter with an instance of FakeMounter inside so we can use its functions
func (FakeMounter) IsLikelyNotMountPoint ¶
func (e FakeMounter) IsLikelyNotMountPoint(file string) (bool, error)
func (FakeMounter) List ¶
func (e FakeMounter) List() ([]mount.MountPoint, error)
This is not part of the interface, just a helper method for tests
func (FakeMounter) Unmount ¶
func (e FakeMounter) Unmount(target string) error
Unmount will return an error if ErrorOnUnmount is true
type FakeRunner ¶
type FakeRunner struct { ReturnValue []byte SideEffect func(command string, args ...string) ([]byte, error) ReturnError error Logger types.Logger CmdNotFound string // contains filtered or unexported fields }
func NewFakeRunner ¶
func NewFakeRunner() *FakeRunner
func (*FakeRunner) ClearCmds ¶
func (r *FakeRunner) ClearCmds()
func (FakeRunner) CmdsMatch ¶
func (r FakeRunner) CmdsMatch(cmdList [][]string) error
CmdsMatch matches the commands list in order. Note HasPrefix is being used to evaluate the match, so expecting initial part of the command is enough to get a match. It facilitates testing commands with dynamic arguments (aka temporary files)
func (*FakeRunner) CommandExists ¶
func (r *FakeRunner) CommandExists(command string) bool
func (FakeRunner) GetCmds ¶
func (r FakeRunner) GetCmds() [][]string
GetCmds returns the list of commands recorded by this FakeRunner instance this is helpful to debug tests
func (FakeRunner) GetLogger ¶
func (r FakeRunner) GetLogger() types.Logger
func (FakeRunner) IncludesCmds ¶
func (r FakeRunner) IncludesCmds(cmdList [][]string) error
IncludesCmds checks the given commands were executed in any order. Note it uses HasPrefix to match commands, see CmdsMatch.
func (FakeRunner) MatchMilestones ¶
func (r FakeRunner) MatchMilestones(cmdList [][]string) error
MatchMilestones matches all the given commands were executed in the provided order. Note it uses HasPrefix to match commands, see CmdsMatch.
func (*FakeRunner) SetLogger ¶
func (r *FakeRunner) SetLogger(logger types.Logger)
type FakeSyscall ¶
type FakeSyscall struct { ErrorOnChroot bool // contains filtered or unexported fields }
FakeSyscall is a test helper method to track calls to syscall It can also fail on Chroot command
func (*FakeSyscall) Chdir ¶
func (f *FakeSyscall) Chdir(_ string) error
func (*FakeSyscall) Chroot ¶
func (f *FakeSyscall) Chroot(path string) error
Chroot will store the chroot call It can return a failure if ErrorOnChroot is true
func (*FakeSyscall) WasChrootCalledWith ¶
func (f *FakeSyscall) WasChrootCalledWith(path string) bool
WasChrootCalledWith is a helper method to check if Chroot was called with the given path
type GhwMock ¶
type GhwMock struct {
// contains filtered or unexported fields
}
GhwMock is used to construct a fake disk to present to ghw when scanning block devices The way this works is ghw will use the existing files in the system to determine the different disks, partitions and mountpoints. It uses /sys/block, /proc/self/mounts and /run/udev/data to gather everything It also has an entrypoint to overwrite the root dir from which the paths are constructed so that allows us to override it easily and make it read from a different location. This mock is used to construct a fake FS with all its needed files on a different chroot and just add a Disk with its partitions and let the struct do its thing creating files and mountpoints and such You can even just pass no disks to simulate a system in which there is no disk/no cos partitions
func (*GhwMock) AddPartitionToDisk ¶
AddPartitionToDisk will add a partition to the given disk and call Clean+CreateDevices, so we recreate all files It makes no effort checking if the disk exists
func (*GhwMock) Clean ¶
func (g *GhwMock) Clean()
Clean will remove the chroot dir and unset the env var
func (*GhwMock) CreateDevices ¶
func (g *GhwMock) CreateDevices()
CreateDevices will create a new context and paths for ghw using the Chroot value as base, then set the env var GHW_ROOT so the ghw library picks that up and then iterate over the disks and partitions and create the necessary files
func (*GhwMock) RemoveDisk ¶
RemoveDisk will remove the files for a disk. It makes no effort to check if the disk exists or not
func (*GhwMock) RemovePartitionFromDisk ¶
RemovePartitionFromDisk will remove the files for a partition It makes no effort checking if the disk/partition/files exist
type LiveBootLoaderMock ¶
func (*LiveBootLoaderMock) PrepareEFI ¶
func (g *LiveBootLoaderMock) PrepareEFI(_, _ string) error
func (*LiveBootLoaderMock) PrepareISO ¶
func (g *LiveBootLoaderMock) PrepareISO(_, _ string) error
type MockEFIVariables ¶ added in v2.2.0
type MockEFIVariables struct {
// contains filtered or unexported fields
}
MockEFIVariables implements an in-memory variable store.
func NewMockEFIVariables ¶ added in v2.2.0
func NewMockEFIVariables() *MockEFIVariables
func (MockEFIVariables) DelVariable ¶ added in v2.2.0
func (m MockEFIVariables) DelVariable(_ efi.GUID, _ string) error
func (MockEFIVariables) GetVariable ¶ added in v2.2.0
func (m MockEFIVariables) GetVariable(guid efi.GUID, name string) (data []byte, attrs efi.VariableAttributes, err error)
GetVariable implements EFIVariables
func (MockEFIVariables) JSON ¶ added in v2.2.0
func (m MockEFIVariables) JSON() ([]byte, error)
JSON renders the MockEFIVariables as an Azure JSON config
func (MockEFIVariables) ListVariables ¶ added in v2.2.0
func (m MockEFIVariables) ListVariables() (out []efi.VariableDescriptor, err error)
ListVariables implements EFIVariables
func (MockEFIVariables) NewFileDevicePath ¶ added in v2.2.0
func (m MockEFIVariables) NewFileDevicePath(fpath string, _ efi_linux.FilePathToDevicePathMode) (efi.DevicePath, error)
func (MockEFIVariables) ReadLoadOption ¶ added in v2.2.0
func (m MockEFIVariables) ReadLoadOption(_ io.Reader) (out *efi.LoadOption, err error)
func (MockEFIVariables) SetVariable ¶ added in v2.2.0
func (m MockEFIVariables) SetVariable(guid efi.GUID, name string, data []byte, attrs efi.VariableAttributes) error
SetVariable implements EFIVariables
func (*MockEFIVariables) WithLoadOptionError ¶ added in v2.2.0
func (m *MockEFIVariables) WithLoadOptionError(err error) *MockEFIVariables