watch

package
v2.0.0-...-9cab126 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const WindowsBufferSizeEnvVar = "COMPOSE_WATCH_WINDOWS_BUFFER_SIZE"

Variables

This section is empty.

Functions

func DesiredWindowsBufferSize

func DesiredWindowsBufferSize() int

func DockerIgnoreTesterFromContents

func DockerIgnoreTesterFromContents(repoRoot string, contents string) (*dockerPathMatcher, error)

func IsChild

func IsChild(dir string, file string) bool

func IsWindowsShortReadError

func IsWindowsShortReadError(err error) bool

func LoadDockerIgnore

func LoadDockerIgnore(repoRoot string) (*dockerPathMatcher, error)

func MaybeIncreaseBufferSize

func MaybeIncreaseBufferSize(w *fsnotify.Watcher)

func NewDockerPatternMatcher

func NewDockerPatternMatcher(repoRoot string, patterns []string) (*dockerPathMatcher, error)

func SanitizeFileName

func SanitizeFileName(name string) string

Types

type CompositePathMatcher

type CompositePathMatcher struct {
	Matchers []PathMatcher
}

func (CompositePathMatcher) Matches

func (c CompositePathMatcher) Matches(f string) (bool, error)

func (CompositePathMatcher) MatchesEntireDir

func (c CompositePathMatcher) MatchesEntireDir(f string) (bool, error)

type EmptyMatcher

type EmptyMatcher struct {
}

func (EmptyMatcher) Matches

func (EmptyMatcher) Matches(f string) (bool, error)

func (EmptyMatcher) MatchesEntireDir

func (EmptyMatcher) MatchesEntireDir(f string) (bool, error)

type FileEvent

type FileEvent struct {
	// contains filtered or unexported fields
}

func NewFileEvent

func NewFileEvent(p string) FileEvent

func (FileEvent) Path

func (e FileEvent) Path() string

type Notify

type Notify interface {
	// Start watching the paths set at init time
	Start() error

	// Stop watching and close all channels
	Close() error

	// A channel to read off incoming file changes
	Events() chan FileEvent

	// A channel to read off show-stopping errors
	Errors() chan error
}

func NewWatcher

func NewWatcher(paths []string, ignore PathMatcher) (Notify, error)

type PathMatcher

type PathMatcher interface {
	Matches(file string) (bool, error)

	// If this matches the entire dir, we can often optimize filetree walks a bit.
	MatchesEntireDir(file string) (bool, error)
}

When we specify directories to watch, we often want to ignore some subset of the files under those directories.

For example: - Watch /src/repo, but ignore /src/repo/.git - Watch /src/repo, but ignore everything in /src/repo/bazel-bin except /src/repo/bazel-bin/app-binary

The PathMatcher inteface helps us manage these ignores.

func EphemeralPathMatcher

func EphemeralPathMatcher() PathMatcher

EphemeralPathMatcher filters out spurious changes that we don't want to rebuild on, like IDE temp/lock files.

This isn't an ideal solution. In an ideal world, the user would put everything to ignore in their tiltignore/dockerignore files. This is a stop-gap so they don't have a terrible experience if those files aren't there or aren't in the right places.

NOTE: The underlying `patternmatcher` is NOT always Goroutine-safe, so this is not a singleton; we create an instance for each watcher currently.

func NewCompositeMatcher

func NewCompositeMatcher(matchers ...PathMatcher) PathMatcher

type TempDir

type TempDir struct {
	// contains filtered or unexported fields
}

TempDir holds a temp directory and allows easy access to new temp directories.

func NewDir

func NewDir(prefix string) (*TempDir, error)

NewDir creates a new TempDir in the default location (typically $TMPDIR)

func NewDirAtRoot

func NewDirAtRoot(root, prefix string) (*TempDir, error)

NewDir creates a new TempDir at the given root.

func NewDirAtSlashTmp

func NewDirAtSlashTmp(prefix string) (*TempDir, error)

NewDirAtSlashTmp creates a new TempDir at /tmp

func (*TempDir) NewDeterministicDir

func (d *TempDir) NewDeterministicDir(name string) (*TempDir, error)

func (*TempDir) NewDir

func (d *TempDir) NewDir(prefix string) (*TempDir, error)

d.NewDir creates a new TempDir under d

func (*TempDir) Path

func (d *TempDir) Path() string

func (*TempDir) TearDown

func (d *TempDir) TearDown() error

type TempDirFixture

type TempDirFixture struct {
	// contains filtered or unexported fields
}

func NewTempDirFixture

func NewTempDirFixture(t testing.TB) *TempDirFixture

func (*TempDirFixture) Chdir

func (f *TempDirFixture) Chdir()

func (*TempDirFixture) CopyFile

func (f *TempDirFixture) CopyFile(originalPath, newPath string)

Returns the full path to the file written.

func (*TempDirFixture) JoinPath

func (f *TempDirFixture) JoinPath(path ...string) string

func (*TempDirFixture) JoinPaths

func (f *TempDirFixture) JoinPaths(paths []string) []string

func (*TempDirFixture) MkdirAll

func (f *TempDirFixture) MkdirAll(path string)

func (*TempDirFixture) NewFile

func (f *TempDirFixture) NewFile(prefix string) (*os.File, error)

func (*TempDirFixture) Path

func (f *TempDirFixture) Path() string

func (*TempDirFixture) ReadFile

func (f *TempDirFixture) ReadFile(path string) string

Read the file.

func (*TempDirFixture) Rm

func (f *TempDirFixture) Rm(pathInRepo string)

func (*TempDirFixture) T

func (f *TempDirFixture) T() testing.TB

func (*TempDirFixture) TempDir

func (f *TempDirFixture) TempDir(prefix string) string

func (*TempDirFixture) TouchFiles

func (f *TempDirFixture) TouchFiles(paths []string)

func (*TempDirFixture) WriteFile

func (f *TempDirFixture) WriteFile(path string, contents string) string

Returns the full path to the file written.

func (f *TempDirFixture) WriteSymlink(linkContents, destPath string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL