Documentation
¶
Index ¶
- func MountTargetExists(path string) (bool, error)
- type CacheMetadata
- type CacheMetadataEntry
- type DefaultExecutor
- func (e DefaultExecutor) DiskUsage(ctx context.Context, path string) (DiskUsage, error)
- func (e DefaultExecutor) MkdirAll(path string, perm os.FileMode) error
- func (e DefaultExecutor) Mount(ctx context.Context, from, to string) error
- func (e DefaultExecutor) RemoveAll(name string) error
- func (e DefaultExecutor) Stat(name string) (os.FileInfo, error)
- func (e DefaultExecutor) WriteFile(name string, data []byte, perm os.FileMode) error
- type DiskUsage
- type Executor
- type ExecutorMock
- func (mock *ExecutorMock) DiskUsage(ctx context.Context, path string) (DiskUsage, error)
- func (mock *ExecutorMock) DiskUsageCalls() []struct{ ... }
- func (mock *ExecutorMock) MkdirAll(path string, perm os.FileMode) error
- func (mock *ExecutorMock) MkdirAllCalls() []struct{ ... }
- func (mock *ExecutorMock) Mount(ctx context.Context, from string, to string) error
- func (mock *ExecutorMock) MountCalls() []struct{ ... }
- func (mock *ExecutorMock) RemoveAll(name string) error
- func (mock *ExecutorMock) RemoveAllCalls() []struct{ ... }
- func (mock *ExecutorMock) Stat(name string) (os.FileInfo, error)
- func (mock *ExecutorMock) StatCalls() []struct{ ... }
- func (mock *ExecutorMock) WriteFile(name string, data []byte, perm os.FileMode) error
- func (mock *ExecutorMock) WriteFileCalls() []struct{ ... }
- type MountRequest
- type MountResponse
- type MountResponseInput
- type MountResponseOutput
- type MountResult
- type Mounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MountTargetExists ¶
MountTargetExists checks if a mount target path exists and has content. For files, it returns true if the file exists. For directories, it returns true only if the directory is non-empty. For symlinks, it follows the link and applies the same logic. Returns false for non-existent paths or broken symlinks.
Types ¶
type CacheMetadata ¶
type CacheMetadata struct {
UpdatedAt string `json:"updatedAt"`
Version int `json:"version"`
UserRequest map[string]CacheMetadataEntry `json:"userRequest"`
}
type CacheMetadataEntry ¶
type DefaultExecutor ¶
type DefaultExecutor struct{}
func (DefaultExecutor) MkdirAll ¶
func (e DefaultExecutor) MkdirAll(path string, perm os.FileMode) error
func (DefaultExecutor) Mount ¶
func (e DefaultExecutor) Mount(ctx context.Context, from, to string) error
func (DefaultExecutor) RemoveAll ¶
func (e DefaultExecutor) RemoveAll(name string) error
type Executor ¶
type Executor interface {
DiskUsage(ctx context.Context, path string) (DiskUsage, error)
MkdirAll(path string, perm os.FileMode) error
Mount(ctx context.Context, from, to string) error
RemoveAll(name string) error
Stat(name string) (os.FileInfo, error)
WriteFile(name string, data []byte, perm os.FileMode) error
}
type ExecutorMock ¶
type ExecutorMock struct {
// DiskUsageFunc mocks the DiskUsage method.
DiskUsageFunc func(ctx context.Context, path string) (DiskUsage, error)
// MkdirAllFunc mocks the MkdirAll method.
MkdirAllFunc func(path string, perm os.FileMode) error
// MountFunc mocks the Mount method.
MountFunc func(ctx context.Context, from string, to string) error
// RemoveAllFunc mocks the RemoveAll method.
RemoveAllFunc func(name string) error
// StatFunc mocks the Stat method.
StatFunc func(name string) (os.FileInfo, error)
// WriteFileFunc mocks the WriteFile method.
WriteFileFunc func(name string, data []byte, perm os.FileMode) error
// contains filtered or unexported fields
}
ExecutorMock is a mock implementation of Executor.
func TestSomethingThatUsesExecutor(t *testing.T) {
// make and configure a mocked Executor
mockedExecutor := &ExecutorMock{
DiskUsageFunc: func(ctx context.Context, path string) (DiskUsage, error) {
panic("mock out the DiskUsage method")
},
MkdirAllFunc: func(path string, perm os.FileMode) error {
panic("mock out the MkdirAll method")
},
MountFunc: func(ctx context.Context, from string, to string) error {
panic("mock out the Mount method")
},
RemoveAllFunc: func(name string) error {
panic("mock out the RemoveAll method")
},
StatFunc: func(name string) (os.FileInfo, error) {
panic("mock out the Stat method")
},
WriteFileFunc: func(name string, data []byte, perm os.FileMode) error {
panic("mock out the WriteFile method")
},
}
// use mockedExecutor in code that requires Executor
// and then make assertions.
}
func (*ExecutorMock) DiskUsageCalls ¶
func (mock *ExecutorMock) DiskUsageCalls() []struct { Ctx context.Context Path string }
DiskUsageCalls gets all the calls that were made to DiskUsage. Check the length with:
len(mockedExecutor.DiskUsageCalls())
func (*ExecutorMock) MkdirAll ¶
func (mock *ExecutorMock) MkdirAll(path string, perm os.FileMode) error
MkdirAll calls MkdirAllFunc.
func (*ExecutorMock) MkdirAllCalls ¶
func (mock *ExecutorMock) MkdirAllCalls() []struct { Path string Perm os.FileMode }
MkdirAllCalls gets all the calls that were made to MkdirAll. Check the length with:
len(mockedExecutor.MkdirAllCalls())
func (*ExecutorMock) MountCalls ¶
func (mock *ExecutorMock) MountCalls() []struct { Ctx context.Context From string To string }
MountCalls gets all the calls that were made to Mount. Check the length with:
len(mockedExecutor.MountCalls())
func (*ExecutorMock) RemoveAll ¶
func (mock *ExecutorMock) RemoveAll(name string) error
RemoveAll calls RemoveAllFunc.
func (*ExecutorMock) RemoveAllCalls ¶
func (mock *ExecutorMock) RemoveAllCalls() []struct { Name string }
RemoveAllCalls gets all the calls that were made to RemoveAll. Check the length with:
len(mockedExecutor.RemoveAllCalls())
func (*ExecutorMock) Stat ¶
func (mock *ExecutorMock) Stat(name string) (os.FileInfo, error)
Stat calls StatFunc.
func (*ExecutorMock) StatCalls ¶
func (mock *ExecutorMock) StatCalls() []struct { Name string }
StatCalls gets all the calls that were made to Stat. Check the length with:
len(mockedExecutor.StatCalls())
func (*ExecutorMock) WriteFileCalls ¶
func (mock *ExecutorMock) WriteFileCalls() []struct { Name string Data []byte Perm os.FileMode }
WriteFileCalls gets all the calls that were made to WriteFile. Check the length with:
len(mockedExecutor.WriteFileCalls())
type MountRequest ¶
type MountRequest struct {
DetectAllModes bool
DetectModes []string
ManualModes []string
ManualPaths []string
}
func (MountRequest) EnabledModes ¶
EnabledModes returns the set of enabled cache modes based on the request. It performs detection as necessary, based on the detect modes specified.
type MountResponse ¶
type MountResponse struct {
Input MountResponseInput `json:"input,omitzero"`
Output MountResponseOutput `json:"output,omitzero"`
}
type MountResponseInput ¶
type MountResponseOutput ¶
type MountResponseOutput struct {
DestructiveMode bool `json:"destructive_mode"`
AddEnvs map[string]string `json:"add_envs,omitzero"`
DiskUsage *DiskUsage `json:"disk_usage,omitzero"` // lookup can fail, so inclusion is optional
Mounts []MountResult `json:"mounts,omitzero"`
RemovedPaths []string `json:"removed_paths,omitzero"`
}
type MountResult ¶
type Mounter ¶
func NewMounter ¶
func (Mounter) Mount ¶
func (m Mounter) Mount(ctx context.Context, req MountRequest) (MountResponse, error)
Mount mounts the cache paths based on the given request.