jx: github.com/jenkins-x/jx/cmd/codegen/util Index | Files

package util

import "github.com/jenkins-x/jx/cmd/codegen/util"


Package Files

cli.go commands.go files.go go.go logger.go strings.go


const (
    // AppName is tge application name for logging.
    AppName = "codegen"
const (
    // DefaultErrorExitCode is the default exit code in case of an error
    DefaultErrorExitCode = 1


var (

    // ErrExit can be used to exit with a non 0 exit code without any error message
    ErrExit = fmt.Errorf("exit")

func AppLogger Uses

func AppLogger() *log.Entry

AppLogger returns the application logger.

func CheckErr Uses

func CheckErr(err error)

CheckErr prints a user friendly error to STDERR and exits with a non-zero exit code.

func ConfigDir Uses

func ConfigDir() (string, error)

ConfigDir returns the JX_HOME directory, creating it if missing

func CopyDirPreserve Uses

func CopyDirPreserve(src string, dst string) error

CopyDirPreserve copies from the src dir to the dst dir if the file does NOT already exist in dst

func CopyFile Uses

func CopyFile(src, dst string) (err error)

CopyFile copies a file from the specified source src to dst. credit https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func DeleteDirContents Uses

func DeleteDirContents(dir string) error

DeleteDirContents removes all the contents of the given directory

func DeleteFile Uses

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 DownloadFile Uses

func DownloadFile(filepath string, url string) (err error)

DownloadFile downloads a file from the given URL

func EnsureGoPath Uses

func EnsureGoPath() error

EnsureGoPath ensures the GOPATH environment variable is set and points to a valid directory.

func FileExists Uses

func FileExists(path string) (bool, error)

FileExists returns true if the specified path exist, false otherwise. An error is returned if and file system operation fails.

func GetClientWithTimeout Uses

func GetClientWithTimeout(duration time.Duration) *http.Client

GetClientWithTimeout returns a client with JX default transport and user specified timeout

func GetModuleDir Uses

func GetModuleDir(moduleDir string, targetRequirement string, gopath string) (string, error)

GetModuleDir determines the directory on disk of the specified module dependency. Returns the empty string if the target requirement is not part of the module graph.

func GetModuleRequirements Uses

func GetModuleRequirements(dir string, gopath string) (map[string]map[string]string, error)

GetModuleRequirements returns the requirements for the GO module rooted in dir It returns a map[<module name>]map[<requirement name>]<requirement version>

func GoGet Uses

func GoGet(path string, version string, gopath string, goModules bool, sourceOnly bool, update bool) error

GoGet runs go get to install the specified binary.

func GoPath Uses

func GoPath() string

GoPath returns the first element of the GOPATH. The empty string is returned if GOPATH is not set.

func GoPathBin Uses

func GoPathBin(gopath string) string

GoPathBin returns the bin directory of the first GOPATH element.

func GoPathMod Uses

func GoPathMod(gopath string) string

GoPathMod returns the modules directory of the first GOPATH element.

func GoPathSrc Uses

func GoPathSrc(gopath string) string

GoPathSrc returns the src directory of the first GOPATH element.

func HomeDir Uses

func HomeDir() string

HomeDir returns the users home directory

func InvalidOptionf Uses

func InvalidOptionf(option string, value interface{}, message string, a ...interface{}) error

InvalidOptionf returns an error that shows the invalid option.

func IsolatedGoPath Uses

func IsolatedGoPath() (string, error)

IsolatedGoPath returns the isolated go path for codegen

func JoinMap Uses

func JoinMap(m map[string]string, pairSep string, keyValueSep string) string

func MissingOption Uses

func MissingOption(name string) error

MissingOption reports a missing command line option using the full name expression.

func SetLevel Uses

func SetLevel(s string) error

SetLevel sets the logging level

type Command Uses

type Command struct {
    Errors             []error
    Dir                string
    Name               string
    Args               []string
    ExponentialBackOff *backoff.ExponentialBackOff
    Timeout            time.Duration
    Out                io.Writer
    Err                io.Writer
    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 Uses

func (c *Command) Attempts() int

Attempts The number of times the command has been executed

func (*Command) CurrentArgs Uses

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

CurrentArgs returns the current command arguments

func (*Command) CurrentDir Uses

func (c *Command) CurrentDir() string

CurrentDir returns the current Dir

func (*Command) CurrentEnv Uses

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

CurrentEnv returns the current environment variables

func (*Command) CurrentName Uses

func (c *Command) CurrentName() string

CurrentName returns the current name of the command

func (*Command) DidError Uses

func (c *Command) DidError() bool

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

func (*Command) DidFail Uses

func (c *Command) DidFail() bool

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

func (*Command) Error Uses

func (c *Command) Error() error

Error returns the last error

func (*Command) Run Uses

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

Run Execute the command and block waiting for return values

func (*Command) RunWithoutRetry Uses

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

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

func (*Command) SetArgs Uses

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

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

func (*Command) SetDir Uses

func (c *Command) SetDir(dir string)

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

func (*Command) SetEnv Uses

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 Uses

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

SetEnvVariable sets an environment variable into the environment

func (*Command) SetExponentialBackOff Uses

func (c *Command) SetExponentialBackOff(backoff *backoff.ExponentialBackOff)

SetExponentialBackOff Setter method for ExponentialBackOff to enable use of interface instead of Command struct

func (*Command) SetName Uses

func (c *Command) SetName(name string)

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

func (*Command) SetTimeout Uses

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

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

func (*Command) String Uses

func (c *Command) String() string

type CommandError Uses

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) Error Uses

func (c CommandError) Error() string

Package util imports 13 packages (graph) and is imported by 3 packages. Updated 2020-02-08. Refresh now. Tools for package owners.