Documentation
¶
Index ¶
- type FileFilter
- type FilePattern
- type LocalRuntime
- type MockRuntime
- func (_m *MockRuntime) CopyFiles(ctx *contexts.Context, src string, dest string) error
- func (_m *MockRuntime) EXPECT() *MockRuntime_Expecter
- func (_m *MockRuntime) ListDirectory(ctx *contexts.Context, path string) ([]string, error)
- func (_m *MockRuntime) SyncFiles(ctx *contexts.Context, src string, dest string, opts SyncFilesOptions) error
- type MockRuntime_CopyFiles_Call
- func (_c *MockRuntime_CopyFiles_Call) Return(_a0 error) *MockRuntime_CopyFiles_Call
- func (_c *MockRuntime_CopyFiles_Call) Run(run func(ctx *contexts.Context, src string, dest string)) *MockRuntime_CopyFiles_Call
- func (_c *MockRuntime_CopyFiles_Call) RunAndReturn(run func(*contexts.Context, string, string) error) *MockRuntime_CopyFiles_Call
- type MockRuntime_Expecter
- func (_e *MockRuntime_Expecter) CopyFiles(ctx interface{}, src interface{}, dest interface{}) *MockRuntime_CopyFiles_Call
- func (_e *MockRuntime_Expecter) ListDirectory(ctx interface{}, path interface{}) *MockRuntime_ListDirectory_Call
- func (_e *MockRuntime_Expecter) SyncFiles(ctx interface{}, src interface{}, dest interface{}, opts interface{}) *MockRuntime_SyncFiles_Call
- type MockRuntime_ListDirectory_Call
- func (_c *MockRuntime_ListDirectory_Call) Return(_a0 []string, _a1 error) *MockRuntime_ListDirectory_Call
- func (_c *MockRuntime_ListDirectory_Call) Run(run func(ctx *contexts.Context, path string)) *MockRuntime_ListDirectory_Call
- func (_c *MockRuntime_ListDirectory_Call) RunAndReturn(run func(*contexts.Context, string) ([]string, error)) *MockRuntime_ListDirectory_Call
- type MockRuntime_SyncFiles_Call
- func (_c *MockRuntime_SyncFiles_Call) Return(_a0 error) *MockRuntime_SyncFiles_Call
- func (_c *MockRuntime_SyncFiles_Call) Run(...) *MockRuntime_SyncFiles_Call
- func (_c *MockRuntime_SyncFiles_Call) RunAndReturn(run func(*contexts.Context, string, string, SyncFilesOptions) error) *MockRuntime_SyncFiles_Call
- type Runtime
- type SyncFilesOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileFilter ¶ added in v0.0.16
type FileFilter struct {
Include []FilePattern `yaml:"include,omitempty"`
Exclude []FilePattern `yaml:"exclude,omitempty"`
}
FileFilter selects which files within a sync are transferred (a whitelist/blacklist).
Include is a whitelist: when non-empty, only files matching at least one Include pattern are transferred. Exclude is a blacklist: any entry matching an Exclude pattern is omitted, and for a directory its whole subtree is pruned. Exclude takes precedence over Include.
Directories are always traversed when only Include patterns are set, so a whitelist of "data/**/*.db" still reaches the nested files (intermediate directories may be left empty). A zero FileFilter (no patterns) transfers everything.
func (FileFilter) IsZero ¶ added in v0.0.16
func (f FileFilter) IsZero() bool
IsZero reports whether the filter constrains nothing (transfers everything).
func (FileFilter) Validate ¶ added in v0.0.16
func (f FileFilter) Validate() error
Validate reports whether every Include/Exclude pattern is well-formed.
type FilePattern ¶ added in v0.0.16
type FilePattern struct {
// Glob is a doublestar glob (https://pkg.go.dev/github.com/bmatcuk/doublestar/v4#Match), matched
// against the entry's slash-separated path relative to the sync root and anchored there. "*" matches
// within a single path segment; "**" matches across segments (any depth, including none). So "logs"
// matches only a top-level "logs", "**/logs" matches a "logs" at any depth, "**/*.tmp" matches ".tmp"
// files anywhere, and "cache/**" matches everything under a top-level "cache".
Glob string `yaml:"glob,omitempty"`
}
FilePattern matches file paths within a sync. Each pattern selects its matcher by which field is set; currently the only matcher is Glob. Modelling a pattern as an object (rather than a bare string) leaves room to add alternative matchers later (e.g. a Regex field) without changing the config shape.
func (FilePattern) Validate ¶ added in v0.0.16
func (p FilePattern) Validate() error
Validate reports whether the pattern is well-formed: exactly one matcher must be set, and it must be syntactically valid.
type LocalRuntime ¶
type LocalRuntime struct{}
func NewLocalRuntime ¶
func NewLocalRuntime() *LocalRuntime
func (*LocalRuntime) CopyFiles ¶
func (lr *LocalRuntime) CopyFiles(ctx *contexts.Context, src, dest string) (err error)
Copies the filesytem object (file, directory, etc.) to the destination path. Special files (such as sockets or device files) are not included.
func (*LocalRuntime) ListDirectory ¶ added in v0.0.15
func (*LocalRuntime) ListDirectory(ctx *contexts.Context, path string) (entries []string, err error)
Lists the names of the immediate subdirectories of the provided path. Non-directory entries are omitted. The returned names are entry names only, not full paths. The directory must exist.
func (*LocalRuntime) SyncFiles ¶
func (lr *LocalRuntime) SyncFiles(ctx *contexts.Context, src, dest string, opts SyncFilesOptions) (err error)
Make the destination path contents match the input directory contents. Special files (such as sockets or device files) are not included.
type MockRuntime ¶
MockRuntime is an autogenerated mock type for the Runtime type
func NewMockRuntime ¶
func NewMockRuntime(t interface {
mock.TestingT
Cleanup(func())
}) *MockRuntime
NewMockRuntime creates a new instance of MockRuntime. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockRuntime) CopyFiles ¶
CopyFiles provides a mock function with given fields: ctx, src, dest
func (*MockRuntime) EXPECT ¶
func (_m *MockRuntime) EXPECT() *MockRuntime_Expecter
func (*MockRuntime) ListDirectory ¶ added in v0.0.15
ListDirectory provides a mock function with given fields: ctx, path
func (*MockRuntime) SyncFiles ¶
func (_m *MockRuntime) SyncFiles(ctx *contexts.Context, src string, dest string, opts SyncFilesOptions) error
SyncFiles provides a mock function with given fields: ctx, src, dest, opts
type MockRuntime_CopyFiles_Call ¶
MockRuntime_CopyFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CopyFiles'
func (*MockRuntime_CopyFiles_Call) Return ¶
func (_c *MockRuntime_CopyFiles_Call) Return(_a0 error) *MockRuntime_CopyFiles_Call
func (*MockRuntime_CopyFiles_Call) Run ¶
func (_c *MockRuntime_CopyFiles_Call) Run(run func(ctx *contexts.Context, src string, dest string)) *MockRuntime_CopyFiles_Call
func (*MockRuntime_CopyFiles_Call) RunAndReturn ¶
func (_c *MockRuntime_CopyFiles_Call) RunAndReturn(run func(*contexts.Context, string, string) error) *MockRuntime_CopyFiles_Call
type MockRuntime_Expecter ¶
type MockRuntime_Expecter struct {
// contains filtered or unexported fields
}
func (*MockRuntime_Expecter) CopyFiles ¶
func (_e *MockRuntime_Expecter) CopyFiles(ctx interface{}, src interface{}, dest interface{}) *MockRuntime_CopyFiles_Call
CopyFiles is a helper method to define mock.On call
- ctx *contexts.Context
- src string
- dest string
func (*MockRuntime_Expecter) ListDirectory ¶ added in v0.0.15
func (_e *MockRuntime_Expecter) ListDirectory(ctx interface{}, path interface{}) *MockRuntime_ListDirectory_Call
ListDirectory is a helper method to define mock.On call
- ctx *contexts.Context
- path string
func (*MockRuntime_Expecter) SyncFiles ¶
func (_e *MockRuntime_Expecter) SyncFiles(ctx interface{}, src interface{}, dest interface{}, opts interface{}) *MockRuntime_SyncFiles_Call
SyncFiles is a helper method to define mock.On call
- ctx *contexts.Context
- src string
- dest string
- opts SyncFilesOptions
type MockRuntime_ListDirectory_Call ¶ added in v0.0.15
MockRuntime_ListDirectory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDirectory'
func (*MockRuntime_ListDirectory_Call) Return ¶ added in v0.0.15
func (_c *MockRuntime_ListDirectory_Call) Return(_a0 []string, _a1 error) *MockRuntime_ListDirectory_Call
func (*MockRuntime_ListDirectory_Call) Run ¶ added in v0.0.15
func (_c *MockRuntime_ListDirectory_Call) Run(run func(ctx *contexts.Context, path string)) *MockRuntime_ListDirectory_Call
func (*MockRuntime_ListDirectory_Call) RunAndReturn ¶ added in v0.0.15
func (_c *MockRuntime_ListDirectory_Call) RunAndReturn(run func(*contexts.Context, string) ([]string, error)) *MockRuntime_ListDirectory_Call
type MockRuntime_SyncFiles_Call ¶
MockRuntime_SyncFiles_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SyncFiles'
func (*MockRuntime_SyncFiles_Call) Return ¶
func (_c *MockRuntime_SyncFiles_Call) Return(_a0 error) *MockRuntime_SyncFiles_Call
func (*MockRuntime_SyncFiles_Call) Run ¶
func (_c *MockRuntime_SyncFiles_Call) Run(run func(ctx *contexts.Context, src string, dest string, opts SyncFilesOptions)) *MockRuntime_SyncFiles_Call
func (*MockRuntime_SyncFiles_Call) RunAndReturn ¶
func (_c *MockRuntime_SyncFiles_Call) RunAndReturn(run func(*contexts.Context, string, string, SyncFilesOptions) error) *MockRuntime_SyncFiles_Call
type Runtime ¶
type Runtime interface {
CopyFiles(ctx *contexts.Context, src, dest string) error
SyncFiles(ctx *contexts.Context, src, dest string, opts SyncFilesOptions) error
ListDirectory(ctx *contexts.Context, path string) ([]string, error)
}
Represents a place (i.e. local or remote) where commands can run.
type SyncFilesOptions ¶ added in v0.0.16
type SyncFilesOptions struct {
// Filter selects which files are transferred (a whitelist/blacklist). The zero value transfers
// everything.
Filter FileFilter
}
SyncFilesOptions are the optional parameters for a file sync.