tempdir

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// The directory that contains a diff for each template rendering step to
	// help with template debugging. Must be enabled by command line flag.
	DebugStepDiffsDirNamePart = "debug-step-diffs-"

	// The temp directory where the "golden-test verify" command writes the "got"
	// output before comparing to the "wanted" output.
	GoldenTestRenderNamePart = "golden-test-"

	// The temp directory where templates perform their actions and "include"
	// into, before it is committed to the user-visible destination directory.
	ScratchDirNamePart = "scratch-"

	// The temp directory that contains the downloaded template.
	TemplateDirNamePart = "template-copy-"

	// The temp directory where the upgrade operation renders the upgraded
	// version of the template, before it is merged with the user-visible
	// destination directory.
	UpgradeMergeDirNamePart = "upgrade-merge-"

	// The temp directory where, during the upgrade process, the output of the
	// patch command is written to. This contains the result of applying every
	// patch in the manifest YAML file to the corresponding
	// included-from-destination file.
	ReversedPatchDirNamePart = "reversed-patch-"

	// The temp directory where files are staged before feeding them to "git
	// diff --no-index". This is needed because git diff doesn't have the
	// ability to override the filename labels in the diff output, you have to
	// actually create a directory with the files in the desired locations.
	GitDiffDirNamePart = "git-diff-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DirTracker

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

DirTracker helps manage the removal of temporary directories when rendering is finished.

func NewDirTracker

func NewDirTracker(fs common.FS, keepTempDirs bool) *DirTracker

NewDirTracker constructs a DirTracker. Use this instead of creating a DirTracker yourself.

keepTempDirs is like a no-op flag; it preserves the temp dirs for debugging rather than removing them.

func (*DirTracker) DeferMaybeRemoveAll

func (t *DirTracker) DeferMaybeRemoveAll(ctx context.Context, outErr *error)

DeferMaybeRemoveAll should be called in a defer to clean up temp dirs, like this:

defer t.DeferMaybeRemoveAll(ctx, &rErr)

func (*DirTracker) MkdirTempTracked

func (t *DirTracker) MkdirTempTracked(dir, pattern string) (string, error)

MkdirTempTracked calls MkdirTemp and also tracks the resulting directory for later cleanup.

func (*DirTracker) Track

func (t *DirTracker) Track(dir string)

Track adds dir to the list of directories to remove.

Jump to

Keyboard shortcuts

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