util

package
v3.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWritePermissions = 0760
)

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

func DeleteFile

func DeleteFile(fileName string) (err error)

DeleteFile deletes a file from the operating system. This should NOT be used to delete any sensitive information because it can easily be recovered. Use DestroyFile to delete sensitive information

func FileExists

func FileExists(path string) (bool, error)

FileExists checks if path exists and is a file

func GenerateSchema

func GenerateSchema(target interface{}) *schemagen.Schema

GenerateSchema generates a JSON schema for the given struct type and returns it.

func HomeDir

func HomeDir() string

func JXBinLocation

func JXBinLocation() (string, error)

JXBinLocation finds the JX config directory and creates a bin directory inside it if it does not already exist. Returns the JX bin path

func PathWithBinary

func PathWithBinary(customPaths ...string) string

PathWithBinary Returns the path to be used to execute a binary from, takes the form JX_HOME/bin:mvnBinDir:customPaths

func SanitizeURL

func SanitizeURL(unsanitizedURL string) string

SanitizeURL sanitizes by stripping the user and password

func ToObjectMap

func ToObjectMap(object interface{}) (map[string]interface{}, error)

ToObjectMap converts the given object into a map of strings/maps using YAML marshalling

func ValidateYaml

func ValidateYaml(target interface{}, data []byte) ([]string, error)

ValidateYaml generates a JSON schema for the given struct type, and then validates the given YAML against that schema, ignoring Containers and missing fields.

Types

type Command

type Command struct {
	Errors  []error
	Dir     string
	Name    string
	Args    []string
	Timeout time.Duration
	Out     io.Writer
	Err     io.Writer
	In      io.Reader
	Env     map[string]string
	// contains filtered or unexported fields
}

Command is a struct containing the details of an external command to be executed

func (*Command) Attempts

func (c *Command) Attempts() int

Attempts The number of times the command has been executed

func (*Command) CurrentArgs

func (c *Command) CurrentArgs() []string

CurrentArgs returns the current command arguments

func (*Command) CurrentDir

func (c *Command) CurrentDir() string

CurrentDir returns the current Dir

func (*Command) CurrentEnv

func (c *Command) CurrentEnv() map[string]string

CurrentEnv returns the current environment variables

func (*Command) CurrentName

func (c *Command) CurrentName() string

CurrentName returns the current name of the command

func (*Command) DidError

func (c *Command) DidError() bool

DidError returns a boolean if any error occurred in any execution of the command

func (*Command) DidFail

func (c *Command) DidFail() bool

DidFail returns a boolean if the command could not complete (errored on every attempt)

func (*Command) Error

func (c *Command) Error() error

Error returns the last error

func (*Command) RunWithoutRetry

func (c *Command) RunWithoutRetry() (string, error)

RunWithoutRetry Execute the command without retrying on failure and block waiting for return values

func (*Command) SetArgs

func (c *Command) SetArgs(args []string)

SetArgs Setter method for Args to enable use of interface instead of Command struct

func (*Command) SetDir

func (c *Command) SetDir(dir string)

SetDir Setter method for Dir to enable use of interface instead of Command struct

func (*Command) SetEnv

func (c *Command) SetEnv(env map[string]string)

SetEnv Setter method for Env to enable use of interface instead of Command struct

func (*Command) SetEnvVariable

func (c *Command) SetEnvVariable(name string, value string)

SetEnvVariable sets an environment variable into the environment

func (*Command) SetName

func (c *Command) SetName(name string)

SetName Setter method for Name to enable use of interface instead of Command struct

func (*Command) SetTimeout

func (c *Command) SetTimeout(timeout time.Duration)

SetTimeout Setter method for Timeout to enable use of interface instead of Command struct

func (*Command) String

func (c *Command) String() string

type CommandError

type CommandError struct {
	Command Command
	Output  string
	// contains filtered or unexported fields
}

CommandError is the error object encapsulating an error from a Command

func (CommandError) Cause

func (c CommandError) Cause() error

func (CommandError) Error

func (c CommandError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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