Documentation ¶
Index ¶
- Variables
- func AvgFloat64(array []float64) float64
- func AvgInt(array []int) float64
- func ClearScreen()
- func DownloadFile(filepath string, url string) error
- func DownloadURL(url string) ([]byte, error)
- func ExtractOwnerRepoFromGitURL(url string) (owner string, repo string, err error)
- func Filter(arr interface{}, cond func(interface{}) bool) interface{}
- func GetShortVersion(version string) (string, bool)
- func GitDir() (string, error)
- func GitRemoteOriginURL() (string, error)
- func GitShortRev() (string, error)
- func HTTPTraceRequest(method, url string, status *int, r io.Reader) (io.Reader, string, error)
- func HTTPTraceResponse(method, url string, status *int, r io.Reader) (io.Reader, string, error)
- func IfThenElse(condition bool, a interface{}, b interface{}) interface{}
- func IsCygwinTerminal(f *os.File) bool
- func IsGitRepo() bool
- func IsValidUUID(u string) bool
- func LabelsToSelector(labels map[string]string) (string, error)
- func NestedMapLookup(m map[string]interface{}, ks ...string) (rval interface{}, err error)
- func OpenInBrowser(url string) error
- func RandomInt(min, max int64) int64
- func RandomString(length int) (string, error)
- func ReadTokenFromStdin(r TokenReader) error
- func Reverse(s interface{})
- func StringInArray(str string, list []string) bool
- func SumFloat64(array []float64) float64
- func SumInt(array []int) int
- func ToplevelDir() (string, error)
- func TruncateString(s string, num int) string
- type GitRemoteURL
- type HttpTraceLog
- type TokenReader
Constants ¶
This section is empty.
Variables ¶
var GitCommand = func(args ...string) (*exec.Cmd, error) { gitExe, err := safeexec.LookPath("git") if err != nil { programName := "git" if runtime.GOOS == "windows" { programName = "Git for Windows" } return nil, fmt.Errorf("unable to find git executable in PATH; please install %s before retrying", programName) } return exec.Command(gitExe, args...), nil }
var IsTerminal = func(f *os.File) bool { return isatty.IsTerminal(f.Fd()) || IsCygwinTerminal(f) }
Functions ¶
func AvgFloat64 ¶ added in v0.21.0
SumFloat64 returns the average of all float64 values of the slice
func ClearScreen ¶ added in v0.20.2
func ClearScreen()
func DownloadFile ¶
DownloadFile will download a url to a local file. It's efficient because it will write as it downloads and not load the whole file into memory.
func DownloadURL ¶ added in v0.6.0
DownloadURL downloads from a given URL and returns the response body
func ExtractOwnerRepoFromGitURL ¶ added in v0.4.0
ExtractOwnerRepoFromGitURL extracts owner and repo from a Git URL: https or ssh url
func GetShortVersion ¶ added in v0.18.0
func GitRemoteOriginURL ¶ added in v0.4.0
func GitShortRev ¶ added in v0.18.0
func HTTPTraceRequest ¶ added in v0.42.1
HTTPTraceRequest - returns a beautified trace log for http requests returns an io.Reader containing the original data presented to allow reuse
func HTTPTraceResponse ¶ added in v0.42.1
HTTPTraceRequest - returns a beautified trace log for http responses returns an io.Reader containing the original data presented to allow reuse
func IfThenElse ¶
func IfThenElse(condition bool, a interface{}, b interface{}) interface{}
IfThenElse evaluates a condition, if true returns the first parameter otherwise the second
func IsCygwinTerminal ¶ added in v0.4.0
func IsGitRepo ¶ added in v0.4.0
func IsGitRepo() bool
IsGitRepo indicates whether the current working directory is a git repository
func IsValidUUID ¶ added in v0.20.0
IsValidUUID indicates whether the string as argument contains a valid UUID
func LabelsToSelector ¶ added in v0.44.0
Turn a mapping of labels into a base64 encoded json payload suitable for querying resources
func NestedMapLookup ¶
NestedMapLookup ... m: a map from strings to other maps or values, of arbitrary depth ks: successive keys to reach an internal or leaf node (variadic) If an internal node is reached, will return the internal map
Returns: (Exactly one of these will be nil) rval: the target node (if found) err: an error created by fmt.Errorf
https://gist.github.com/ChristopherThorpe/fd3720efe2ba83c929bf4105719ee967 Licensed under the CC by 4.0 https://creativecommons.org/licenses/by/4.0/
func OpenInBrowser ¶ added in v0.3.0
OpenInBrowser opens the url in a web browser based on OS
func RandomString ¶ added in v0.3.0
RandomString generates a random string of a given length
func ReadTokenFromStdin ¶ added in v0.31.0
func ReadTokenFromStdin(r TokenReader) error
ReadTokenFromStdin - attempts to read token from stdin or any io.ReaderCloser provided. This function will timeout after 1 second(s) if no input is detected from the reader. Note that this short timeout is due to expectation that the token will be presented instantly via stdin
func StringInArray ¶
StringInArray indicates whether a string value is contained in an array or slice
func SumFloat64 ¶ added in v0.11.0
SumFloat64 returns the sum of all float64 values of the slice
func ToplevelDir ¶ added in v0.4.0
ToplevelDir returns the top-level directory path of the current repository
func TruncateString ¶ added in v0.6.0
TruncateString truncates the given string to the num provided and adds an ellipsis (...).
Types ¶
type GitRemoteURL ¶ added in v0.4.0
type GitRemoteURL struct { Proto string // https , ssh , git User string // optional Host string // host or host:port Path string // full path to the repo (without .git ext) // contains filtered or unexported fields }
func ParseGitRemoteOriginURL ¶ added in v0.4.0
func ParseGitRemoteOriginURL(url string) (*GitRemoteURL, error)
ParseGitRemoteOriginURL parses a git remote origin url into a struct that can be uniquely identified regardless the used protocol
func (*GitRemoteURL) Hash ¶ added in v0.4.0
func (grURL *GitRemoteURL) Hash() string
Hash computes the hash for a git remote URL only on non changing fields: different protocol or user can still refer to the same remote origin
func (*GitRemoteURL) String ¶ added in v0.4.0
func (grURL *GitRemoteURL) String() string
String returns the original raw URL of the git remote
type HttpTraceLog ¶ added in v0.42.1
type HttpTraceLog struct { StatusCode *int Response *string Request *string Method string URL string }
HTTPTraceLog used to fill in traceTemplate
func (*HttpTraceLog) String ¶ added in v0.42.1
func (h *HttpTraceLog) String() string
type TokenReader ¶ added in v0.31.0
type TokenReader interface { GetToken() string SetToken(string) Reader() io.ReadCloser }