types

package
v0.0.0-...-7da0e45 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileNotExist occurs when a file is given that does not exist when its existence is required.
	ErrFileNotExist = errors.New("no such file or directory")
	// ErrCannotOpenSrc occurs when a src file cannot be opened with os.Open().
	ErrCannotOpenSrc = errors.New("source file cannot be opened")
	// ErrCannotStatFile occurs when a file receives an error from get os.Stat().
	ErrCannotStatFile = errors.New("cannot stat file, check that file path is accessible")
	// ErrCannotChmodFile occurs when an error is received trying to change permissions on a file.
	ErrCannotChmodFile = errors.New("cannot change permissions on file")
	// ErrCannotCreateTmpFile occurs when an error is received attempting to create a temporary file for atomic copy.
	ErrCannotCreateTmpFile = errors.New("temp file cannot be created")
	// ErrCannotOpenOrCreateDstFile occurs when an error is received attempting to open or create destination file during non-atomic copy.
	ErrCannotOpenOrCreateDstFile = errors.New("destination file cannot be created")
	// ErrCannotRenameTempFile occurs when an error is received trying to rename the temporary copy file to the destination.
	ErrCannotRenameTempFile = errors.New("cannot rename temp file, check file or directory permissions")
	// ErrOmittingDir occurs when attempting to copy a directory but Options.Recursive is not set to true.
	ErrOmittingDir = errors.New("Options.Recursive is not true, omitting directory")
	// ErrWithParentsDstMustBeDir occurs when the destination is expected to be an existing directory but is not
	// present or accessible.
	ErrWithParentsDstMustBeDir = errors.New("with Options.Parents, the destination must be a directory")
	// ErrCannotOverwriteNonDir occurs when attempting to copy a directory to a non-directory.
	ErrCannotOverwriteNonDir = errors.New("cannot overwrite non-directory")
	// ErrReadingSrcDir occurs when attempting to read contents of the source directory fails
	ErrReadingSrcDir = errors.New("cannot read source directory, check source directory permissions")
	// ErrWritingFileToExistingDir occurs when attempting to write a file to an existing directory.
	// See AppendNameToPath option for a more dynamic approach.
	ErrWritingFileToExistingDir = errors.New("cannot overwrite existing directory with file")
	// ErrInvalidBackupControlValue occurs when a control value is given to the Backup option, but the value is invalid.
	ErrInvalidBackupControlValue = errors.New("invalid backup value, valid values are 'off', 'simple', 'existing', 'numbered'")
)

Functions

func CheckBinary

func CheckBinary(path string) error

EnsureBinary ensures the file exists and is executable, or returns an error

func Copy

func Copy(src, dst string, opts Options) (err error)

Copy will copy src to dst. Behavior is determined by the given Options.

func SimpleCopy

func SimpleCopy(src, dst string) error

SimpleCopy will src to dst with default Options.

Types

type Config

type Config struct {
	Home                string
	Name                string
	AllowDownload       bool
	Port                string
	RestartAfterUpgrade bool
}

Config is the information passed in to control the daemon

func GetConfigFromEnv

func GetConfigFromEnv() (*Config, error)

GetConfigFromEnv will read the environmental variables into a config and then Validate it is reasonable

func (*Config) CurrentBin

func (cfg *Config) CurrentBin() (string, error)

CurrentBin is the path to the currently selected binary (genesis if no link is set) This will resolve the symlink to the underlying directory to make it easier to debug

func (*Config) DownloadCode

func (cfg *Config) DownloadCode(upgradeName string) string

func (*Config) GenesisBin

func (cfg *Config) GenesisBin() string

GenesisBin is the path to the genesis binary - must be in place to start manager

func (*Config) GetPort

func (cfg *Config) GetPort() string

func (*Config) Root

func (cfg *Config) Root() string

Root returns the root directory where all info lives

func (*Config) SetCurrentUpgrade

func (cfg *Config) SetCurrentUpgrade(upgradeName string) error

SetCurrentUpgrade sets the named upgrade to be the current link, returns error if this binary doesn't exist

func (*Config) SymLinkToGenesis

func (cfg *Config) SymLinkToGenesis() (string, error)

Symlink to genesis

func (*Config) UpgradeBin

func (cfg *Config) UpgradeBin(upgradeName string) string

UpgradeBin is the path to the binary for the named upgrade

func (*Config) UpgradeDir

func (cfg *Config) UpgradeDir(upgradeName string) string

UpgradeDir is the directory named upgrade

func (*Config) Validate

func (cfg *Config) Validate() error

Validate returns an error if this config is invalid. it enforces Home/upgrade_manager is a valid directory and exists, and that Name is set

type File

type File struct {
	// Path is the path to the src file.
	Path string
	// contains filtered or unexported fields
}

File describes a file and associated options for operations on the file.

func NewFile

func NewFile(path string) *File

NewFile creates a new File.

type Options

type Options struct {
	// AppendNameToPath will, when attempting to copy a file to an existing directory, automatically
	// create the file with the same name in the destination directory.  While CP uses this behavior
	// by default it is an assumption better left to the client in a programmatic setting.
	AppendNameToPath bool
	// Atomic will copy contents to a temporary file in the destination's parent directory first, then
	// rename the file to ensure the operation is atomic.
	Atomic bool
	// Backup makes a backup of each existing destination file. The backup suffix is '~'. Acceptable
	// control values are:
	//   - "off"       no backup will be made (default)
	//   - "simple"    always make simple backups
	//   - "numbered"  make numbered backups
	//   - "existing"  numbered if numbered backups exist, simple otherwise
	Backup string
	// Link creates hard links to files instead of copying them.
	Link bool
	// MkdirAll will use os.MkdirAll to create the destination directory if it does not exist, along with
	// any necessary parents.
	MkdirAll bool

	// NoClobber will not let an existing file be overwritten.
	NoClobber bool
	// Parents will create source directories in dst if they do not already exist. ErrWithParentsDstMustBeDir
	// is returned if destination is not a directory.
	Parents bool
	// Recursive will recurse through sub directories if set true.
	Recursive bool
	// InfoLogFunc will, if defined, handle logging info messages.
	InfoLogFunc func(string)
	// DebugLogFunc will, if defined, handle logging debug messages.
	DebugLogFunc func(string)
	// contains filtered or unexported fields
}

Options directly represent command line flags associated with GNU file operations.

type UpgradeInfo

type UpgradeInfo struct {
	Name    string
	Height  int64
	Version string
}

UpgradeInfo is the details from the regexp

func (*UpgradeInfo) SetUpgrade

func (ui *UpgradeInfo) SetUpgrade(s string) error

Jump to

Keyboard shortcuts

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