Documentation
¶
Index ¶
- type ErrorMounter
- func (e ErrorMounter) GetMountRefs(pathname string) ([]string, error)
- func (e ErrorMounter) IsLikelyNotMountPoint(file string) (bool, error)
- func (e ErrorMounter) List() ([]mount.MountPoint, error)
- func (e ErrorMounter) Mount(source string, target string, fstype string, options []string) error
- func (e ErrorMounter) MountSensitive(source string, target string, fstype string, options []string, ...) error
- func (e ErrorMounter) MountSensitiveWithoutSystemd(source string, target string, fstype string, options []string, ...) error
- func (e ErrorMounter) MountSensitiveWithoutSystemdWithMountFlags(source string, target string, fstype string, options []string, ...) error
- func (e ErrorMounter) Unmount(target string) error
- type FakeCloudInitRunner
- type FakeHTTPClient
- type FakeLuet
- func (l FakeLuet) OverrideConfig(config *luetTypes.LuetConfig)
- func (l *FakeLuet) Unpack(target string, image string, local bool) error
- func (l FakeLuet) UnpackCalled() bool
- func (l FakeLuet) UnpackChannelCalled() bool
- func (l *FakeLuet) UnpackFromChannel(target string, pkg string, repos ...v1.Repository) error
- type FakeRunner
- func (r *FakeRunner) ClearCmds()
- func (r FakeRunner) CmdsMatch(cmdList [][]string) error
- func (r FakeRunner) GetLogger() v1.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(cmd *exec.Cmd) ([]byte, error)
- func (r *FakeRunner) SetLogger(logger v1.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)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorMounter ¶
ErrorMounter is a fake mounter for tests that can error out.
func NewErrorMounter ¶
func NewErrorMounter() *ErrorMounter
NewErrorMounter returns an ErrorMounter with an instance of FakeMounter inside so we can use its functions
func (ErrorMounter) GetMountRefs ¶
func (e ErrorMounter) GetMountRefs(pathname string) ([]string, error)
func (ErrorMounter) IsLikelyNotMountPoint ¶
func (e ErrorMounter) IsLikelyNotMountPoint(file string) (bool, error)
func (ErrorMounter) List ¶
func (e ErrorMounter) List() ([]mount.MountPoint, error)
func (ErrorMounter) MountSensitive ¶
func (ErrorMounter) MountSensitiveWithoutSystemd ¶
func (ErrorMounter) MountSensitiveWithoutSystemdWithMountFlags ¶
func (ErrorMounter) Unmount ¶
func (e ErrorMounter) Unmount(target string) error
Unmount will return an error if ErrorOnUnmount is true
type FakeCloudInitRunner ¶
func (*FakeCloudInitRunner) Run ¶
func (ci *FakeCloudInitRunner) Run(stage string, args ...string) error
func (*FakeCloudInitRunner) SetModifier ¶
func (ci *FakeCloudInitRunner) SetModifier(modifier schema.Modifier)
type FakeHTTPClient ¶ added in v0.0.14
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 ¶ added in v0.0.14
GetURL will return a FakeHttpBody and store the url call into ClientCalls
func (*FakeHTTPClient) WasGetCalledWith ¶ added in v0.0.14
func (m *FakeHTTPClient) WasGetCalledWith(url string) bool
WasGetCalledWith is a helper method to confirm that the client wazs called with the give url
type FakeLuet ¶
type FakeLuet struct { OnUnpackError bool OnUnpackFromChannelError bool UnpackSideEffect func(string, string, bool) error UnpackFromChannelSideEffect func(string, string, ...v1.Repository) error // contains filtered or unexported fields }
func NewFakeLuet ¶
func NewFakeLuet() *FakeLuet
func (FakeLuet) OverrideConfig ¶
func (l FakeLuet) OverrideConfig(config *luetTypes.LuetConfig)
func (FakeLuet) UnpackCalled ¶
func (FakeLuet) UnpackChannelCalled ¶
func (*FakeLuet) UnpackFromChannel ¶
type FakeRunner ¶
type FakeRunner struct { ReturnValue []byte SideEffect func(command string, args ...string) ([]byte, error) ReturnError error Logger v1.Logger // 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) GetLogger ¶ added in v0.0.14
func (r FakeRunner) GetLogger() v1.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 ¶ added in v0.0.14
func (r *FakeRunner) SetLogger(logger v1.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(path 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 ¶ added in v0.0.14
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 ¶ added in v0.0.14
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 ¶ added in v0.0.14
func (g *GhwMock) Clean()
Clean will remove the chroot dir and unset the env var
func (*GhwMock) CreateDevices ¶ added in v0.0.14
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 ¶ added in v0.0.14
RemoveDisk will remove the files for a disk. It makes no effort to check if the disk exists or not
func (*GhwMock) RemovePartitionFromDisk ¶ added in v0.0.14
RemovePartitionFromDisk will remove the files for a partition It makes no effort checking if the disk/partition/files exist