util

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BinFileName is the name of the executing binary.
	BinFileName string

	// BinFilePath is the full path of the executing binary.
	BinFilePath string

	// BinFileDirPath is the full path of the executing binary's parent
	// directory.
	BinFileDirPath string

	// UnitFileName is the name of the SystemD service's unit file.
	UnitFileName string

	// UnitFilePath is the path to the SystemD service's unit file.
	UnitFilePath string

	// InitFileName is the name of the SystemV service's unit file.
	InitFileName string

	// InitFilePath is the path to the SystemV service's init script.
	InitFilePath string

	// PIDFileName is the name of the PID file.
	PIDFileName string

	// DotDirName is the name of the hidden app directory.
	DotDirName string
)
View Source
var ErrHostDetectionFailed = errors.New("host detection failed")

ErrHostDetectionFailed is returned when ActivateLibStorage is invoked and the there is no host specified in the configuration file and no existing host was detected locally.

View Source
var ErrMissingService = goof.New("client must specify service")

ErrMissingService occurs when the client configuration is missing the property "libstorage.service" either at the root or as part of a module definition.

Functions

func ActivateLibStorage added in v0.4.0

func ActivateLibStorage(
	ctx apitypes.Context,
	config gofig.Config) (apitypes.Context, gofig.Config, <-chan error, error)

ActivateLibStorage activates libStorage and returns a possibly mutated context.

func AddKnownHost added in v0.9.0

func AddKnownHost(
	ctx apitypes.Context,
	knownHostPath,
	host, algo string,
	fingerprint []byte) error

AddKnownHost adds unknown host to know_hosts file

func AssertTrustedHost added in v0.9.0

func AssertTrustedHost(
	ctx apitypes.Context,
	host,
	algo string,
	fingerprint []byte,
) bool

AssertTrustedHost presents the user with a onscreen prompt to accept orreject a host as a trusted, known host.

func CreateSelfCert added in v0.9.0

func CreateSelfCert(
	ctx apitypes.Context,
	certPath, keyPath, host string) error

CreateSelfCert creates a self-signed certificate and a private key pair.

func EnvFilePath added in v0.6.4

func EnvFilePath(ctx apitypes.Context) string

EnvFilePath returns the path to the REX-Ray env file.

func EtcFilePath

func EtcFilePath(ctx apitypes.Context, fileName string) string

EtcFilePath returns the path to a file inside the REX-Ray etc directory with the provided file name.

func FindFlagVal added in v0.10.1

func FindFlagVal(name string, args ...string) (string, []int)

FindFlagVal looks at the provided list of arguments and attempts to find the value for the specified flag. The indicies of the arguments that are the flag and its value are also returned. If the flag is specified as --flag=val then only a single index will be returned.

func GetPrefix

func GetPrefix(ctx apitypes.Context) string

GetPrefix gets the root path to the REX-Ray data.

func Install

func Install(args ...string)

Install executes the system install command.

func InstallChownRoot

func InstallChownRoot(args ...string)

InstallChownRoot executes the system install command and chowns the target to the root user and group.

func InstallDirChownRoot

func InstallDirChownRoot(dirPath string)

InstallDirChownRoot executes the system install command with a -d flag and chowns the target to the root user and group.

func IsAddressActive added in v0.6.2

func IsAddressActive(proto, addr string) bool

IsAddressActive returns a flag indicating whether or not a an address is responding to connection attempts. This does not validate whether the address is using TLS or such a connection is possible.

func IsLocalServerActive added in v0.4.0

func IsLocalServerActive(
	ctx apitypes.Context, config gofig.Config) (host string, running bool)

IsLocalServerActive returns a flag indicating whether or not a local libStorage is already running.

func IsPrefixed

func IsPrefixed(ctx apitypes.Context) bool

IsPrefixed determines whether REX-Ray is prefixed.

func IsTerminal added in v0.10.1

func IsTerminal(w io.Writer) bool

IsTerminal returns a flag indicating whether or not the provided writer is connected to a terminal device.

func LogFile

func LogFile(ctx apitypes.Context, fileName string) (io.Writer, error)

LogFile returns a writer to a file inside the REX-Ray log directory with the provided file name.

func LogFilePath

func LogFilePath(ctx apitypes.Context, fileName string) string

LogFilePath returns the path to a file inside the REX-Ray log directory with the provided file name.

func NewClient added in v0.6.4

func NewClient(
	ctx apitypes.Context, config gofig.Config) (apitypes.Client, error)

NewClient returns a new libStorage client.

func NewConfig added in v0.6.4

func NewConfig(ctx apitypes.Context) (config gofig.Config)

NewConfig returns a new config object.

func NewWriterFor added in v0.11.0

func NewWriterFor(f func(msg string, args ...interface{})) io.Writer

NewWriterFor returns an io.Writer that will write data using the provided function.

func PidFilePath

func PidFilePath(ctx apitypes.Context) string

PidFilePath returns the path to the REX-Ray PID file.

func PrintVersion

func PrintVersion(out io.Writer)

PrintVersion prints the current version information to the provided writer.

func ReadPidFile

func ReadPidFile(ctx apitypes.Context) (int, error)

ReadPidFile reads the REX-Ray PID from the PID file.

func ReadSpecFile added in v0.6.2

func ReadSpecFile(ctx apitypes.Context) (string, error)

ReadSpecFile reads the REX-Ray host address from the spec file.

func RunFilePath added in v0.4.0

func RunFilePath(ctx apitypes.Context, fileName string) string

RunFilePath returns the path to a file inside the REX-Ray run directory with the provided file name.

func ScriptDirPath added in v0.6.4

func ScriptDirPath(ctx apitypes.Context) string

ScriptDirPath returns the path to the REX-Ray script directory.

func ScriptFilePath added in v0.6.4

func ScriptFilePath(ctx apitypes.Context, fileName string) string

ScriptFilePath returns the path to a file inside the REX-Ray script directory with the provided file name.

func SpecFilePath added in v0.6.2

func SpecFilePath(ctx apitypes.Context) string

SpecFilePath returns the path to the REX-Ray spec file.

func StdOutAndLogFile

func StdOutAndLogFile(ctx apitypes.Context, fileName string) (io.Writer, error)

StdOutAndLogFile returns a mutltiplexed writer for the current process's stdout descriptor and a REX-Ray log file with the provided name.

func ValidateConfig added in v0.6.4

func ValidateConfig(path string)

ValidateConfig validates a provided configuration file.

func WaitUntilLibStorageStopped added in v0.4.0

func WaitUntilLibStorageStopped(ctx apitypes.Context, errs <-chan error)

WaitUntilLibStorageStopped blocks until libStorage is stopped.

func WritePidFile

func WritePidFile(ctx apitypes.Context, pid int) error

WritePidFile writes the current process ID to the REX-Ray PID file.

func WriteSpecFile added in v0.6.2

func WriteSpecFile(ctx apitypes.Context, host string) error

WriteSpecFile writes the current host address to the REX-Ray spec file.

Types

This section is empty.

Jump to

Keyboard shortcuts

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