stage

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CopyConfig

type CopyConfig struct {
	// RemovableDirs holds destination absolute paths of all dirs which are allowed to be removed.
	// If it is nil, all destination dirs may be removed.
	RemovableDirs *cage_strings.Set

	// RemovableFiles holds destination absolute paths of all files which are allowed to be removed.
	// If it is nil, all destination files may be removed.
	RemovableFiles *cage_strings.Set

	DryRun bool
}

type Plan

type Plan struct {
	// Add holds relative paths of files that exist in the stage but not the destination.
	Add *cage_strings.Set

	// Overwrite holds relative paths of files that exist in the stage and also the destination,
	// and the latter will be overwritten because the content has changed.
	Overwrite *cage_strings.Set

	// Remove holds relative paths of files that do not exist in the stage and but do in the destination.
	Remove *cage_strings.Set
}

func NewPlan

func NewPlan() *Plan

type Stage

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

func NewStage

func NewStage(basePath string) *Stage

func NewTempDirStage

func NewTempDirStage(basePathPrefix string) (*Stage, error)

NewTempDirStage create the stage with ioutil.TempDir.

For example, on Linux a prefix of "stage" would create a directory like "/tmp/stage725468197".

func (*Stage) AddFileByName

func (s *Stage) AddFileByName(relPath string) error

AddFileByName registers a stage file for copying.

It is similar to AddFileByObject except that it opens the file to obtain the object/descriptor.

func (*Stage) AddFileByObject

func (s *Stage) AddFileByObject(relPath string, fd *os.File)

AddFileByObject a stage file for copying.

It is similar to AddFileByName except that it excepts the object/descriptor as a parameter.

func (*Stage) BasePath

func (s *Stage) BasePath() string

BasePath returns the path to the stage root.

func (*Stage) Copy

func (s *Stage) Copy(dstPath string, cfgs ...CopyConfig) (plan *Plan, errs []error)

Output makes a copy of the stage's files in a destination directory.

If the destination does not exist, it will be created.

An optional CopyConfig will replace the default (zero) value.

func (*Stage) CopyFileAll

func (s *Stage) CopyFileAll(srcPath, dstRelPath string, fileMode, dirMode os.FileMode) (*os.File, error)

CopyFileAll adds a copy of a non-stage file into the stage at the selected relative path and all non-existent ancestor directories.

func (*Stage) CreateFileAll

func (s *Stage) CreateFileAll(relPath string, fileMode, dirMode os.FileMode) (*os.File, error)

CreateFileAll creates a new stage file and all non-existent ancestor directories.

func (*Stage) MkdirAll

func (s *Stage) MkdirAll(relPath string, dirMode os.FileMode) error

MkdirAll creates a new stage directory and all non-existent ancestor directories.

func (*Stage) Output

func (s *Stage) Output() (errs []error)

func (*Stage) OverwriteSkip

func (s *Stage) OverwriteSkip(destAbsPath string)

OverwriteSkip marks an absolute path in the destination tree that should not be overwritten or removed.

func (*Stage) Path

func (s *Stage) Path(relPathParts ...string) string

func (*Stage) Rename

func (s *Stage) Rename(fromRelPath, toRelPath string)

Rename registers a relative path in the stage to be a new relative path during the copy process.

Jump to

Keyboard shortcuts

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