pkg

package
v0.0.0-...-ac49fc5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

MIT License

Copyright (c) 2021 Rally Health, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2021 Rally Health, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2021 Rally Health, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2021 Rally Health, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const (
	Black = iota + 30
	Red
	Green
	Brown // Looks more like yellow on most terminal emulators
	Blue
	Magenta
	Cyan
	White
	Underline
	Default
)

Foreground color codes

View Source
const (
	First = Black
	Last  = White
)

For iterating through all color codes

View Source
const (
	// ASCIIFmt is a format specifer for a ECMA-48 color string
	ASCIIFmt = "\033[%d;%dm"
	// ASCIIReset is a reset code that restores the colors to their defaults
	ASCIIReset = "\033[0m"
	// ASCIIFmtReset is a combination of ASCIIFmt and ASCIIReset with a value is sandwiched in between.
	ASCIIFmtReset = "\033[%d;%dm%v\033[0m"

	// fmt.Sprintf can't accept arguments in the form fmt.Sprintf("%s %s %s %s", "a", "b", []interface{ "c", "d"}...)
	// see Encode for the workaround that uses this constant
	ASCIIFmtFmtReset = "\033[%d;%dm%%v\033[0m"
)
View Source
const Query = `` /* 485-byte string literal not displayed */

Variables

View Source
var HueToString = map[int]string{
	Black:   "black",
	Blue:    "blue",
	Brown:   "brown",
	Cyan:    "cyan",
	Default: "default",
	Green:   "green",
	Magenta: "magenta",
	Red:     "red",
	White:   "white",
}

HueToString is a map of hue color codes to their names

View Source
var StringToHue = map[string]int{
	"black":   Black,
	"blue":    Blue,
	"brown":   Brown,
	"cyan":    Cyan,
	"default": Default,
	"green":   Green,
	"magenta": Magenta,
	"red":     Red,
	"white":   White,
}

StringToHue is a map of hue strings to color codes

Functions

func AutoLocateJob

func AutoLocateJob(args []string, branch string, Jenky *gojenkins.Jenkins) (*gojenkins.Job, string)

func BatchScript

func BatchScript(requests []*http.Request, concurrencyLimit int) []result

boundedParallelGet sends requests in parallel but only up to a certain limit, and furthermore it's only parallel up to the amount of CPUs but is always concurrent up to the concurrency limit

func BuildJobIndex

func BuildJobIndex(Jenky *gojenkins.Jenkins)

func BuildScriptRequest

func BuildScriptRequest(J *gojenkins.Jenkins, team string, script string) *http.Request

func FindCurrentRepoJobs

func FindCurrentRepoJobs() []string

func FollowBuild

func FollowBuild(B *gojenkins.Build)

func GenerateParameterList

func GenerateParameterList(jobBatch BatchJob) []map[string]string

func GetAffiliatedJobs

func GetAffiliatedJobs(url string) []string

func GetBuild

func GetBuild(J *gojenkins.Jenkins, path string, num int64) *gojenkins.Build

func GetCurrentBranch

func GetCurrentBranch() string

func GetCurrentGitRepo

func GetCurrentGitRepo() string

func GetCurrentPROfBranch

func GetCurrentPROfBranch() string

func GetInnerJobs

func GetInnerJobs(J *gojenkins.Jenkins, job *gojenkins.Job) []*gojenkins.Job

func GetJobParameters

func GetJobParameters(J *gojenkins.Jenkins, path string) map[string]gojenkins.ParameterDefinition

func GetJobs

func GetJobs(J *gojenkins.Jenkins) []*gojenkins.Job

func GetNestedJob

func GetNestedJob(J *gojenkins.Jenkins, path string) (*gojenkins.Job, error)

func InvokeBatchJob

func InvokeBatchJob(Jenky *gojenkins.Jenkins, jobBatch BatchJob) error

func InvokeJob

func InvokeJob(Jenky *gojenkins.Jenkins, thejob *gojenkins.Job, choices map[string]string)

func IsGitDirectory

func IsGitDirectory() bool

func RefreshJobIndex

func RefreshJobIndex(j *gojenkins.Jenkins)

func RunJobList

func RunJobList(j JobList, Jenky *gojenkins.Jenkins) error

func RunScript

func RunScript(J *gojenkins.Jenkins, team string, script string) (string, error)

func ValidateBatchJob

func ValidateBatchJob(jl JobList) bool

Types

type BatchJob

type BatchJob struct {
	Job        string              `yaml:"Job" `
	Variables  map[string]string   `yaml:"Variables" `
	Substitute map[string][]string `yaml:"Substitute"`
}

type Build

type Build struct {
	Job         string
	BuildNumber int64
}

func ParseBuildPath

func ParseBuildPath(url string) Build

type Hue

type Hue struct {
	// contains filtered or unexported fields
}

Hue holds the foreground color and background color as integers

func New

func New(fg, bg int) *Hue

New creates a new hue object with foreground and background colors specified.

func (*Hue) Bg

func (h *Hue) Bg() int

func (*Hue) Fg

func (h *Hue) Fg() int

func (*Hue) Print

func (h *Hue) Print(a ...interface{})

Print behaves like fmt.Print, except it colorizes the output

func (*Hue) Printf

func (h *Hue) Printf(format string, a ...interface{})

Printf behaves like fmt.Printf, except it colorizes the output

func (*Hue) Println

func (h *Hue) Println(a ...interface{})

Println behaves like fmt.Println, except it colorizes the output

func (*Hue) SetBg

func (h *Hue) SetBg(c int)

func (*Hue) SetFg

func (h *Hue) SetFg(c int)

func (*Hue) Sprintf

func (h *Hue) Sprintf(format string, a ...interface{}) String

Sprintf behaves like fmt.Sprintf, except it colorizes the output String

type JobIndex

type JobIndex struct {
	// contains filtered or unexported fields
}

type JobList

type JobList struct {
	Batch []BatchJob `yaml:"BatchJobs"`
}

func ReadBatchJob

func ReadBatchJob(content []byte) JobList

func ReadBatchJobFile

func ReadBatchJobFile(filename string) JobList

type RegexpWriter

type RegexpWriter struct {
	// contains filtered or unexported fields
}

RegexpWriter implements colorization for a io.Writer object by processing a set of rules. Rules are hue objects assocated with regular expressions.

func NewRegexpWriter

func NewRegexpWriter(w io.Writer) *RegexpWriter

NewRegexpWriter returns a new RegexpWriter

func (*RegexpWriter) AddRule

func (w *RegexpWriter) AddRule(h *Hue, re *regexp.Regexp)

AddRule binds a hue to a regular expression.

func (*RegexpWriter) AddRuleString

func (w *RegexpWriter) AddRuleString(h *Hue, s string)

AddRuleString binds a hue to the regexp in the string 's'. Similar to AddRule, except the caller passes in an uncompiled regexp.

func (*RegexpWriter) AddRuleStringPOSIX

func (w *RegexpWriter) AddRuleStringPOSIX(h *Hue, s string)

AddRuleStringPOSIX binds a hue to the POSIX regexp in the string 's'. Similar to AddRule, except the caller passes in an uncompiled POSIX regexp.

func (*RegexpWriter) FlushRules

func (w *RegexpWriter) FlushRules()

FlushRules deletes all rules added with AddRule from Writer

func (*RegexpWriter) PrintRules

func (w *RegexpWriter) PrintRules()

PrintRules prints out the rules

func (RegexpWriter) Write

func (w RegexpWriter) Write(p []byte) (n int, err error)

Write writes the contents of p into the buffer after processesing the regexp rules added to Writer with AddRule. Write colorizes the contents as it writes to the underlying writer object.

func (RegexpWriter) WriteString

func (w RegexpWriter) WriteString(s string) (n int, err error)

WriteString is similar to Write, except it writes a string to the underlying buffer instead of a byte slice.

type String

type String string

String is a string containing ECMA-48 color codes. Its purpose is to remind the user at compile time that it differs from the string builtin.

func Encode

func Encode(h *Hue, a ...interface{}) String

Encode encapsulates interface a's string representation with the ECMA-40 color codes stored in the hue structure.

func (String) Decode

func (hs String) Decode() (s string)

Decode strips all color data from the String object and returns a standard string

type Writer

type Writer struct {
	*Hue
	// contains filtered or unexported fields
}

Writer implements colorization for an underlying io.Writer object

func NewWriter

func NewWriter(w io.Writer, h *Hue) *Writer

NewWriter returns a new Writer with the hue 'h'

func (*Writer) SetHue

func (w *Writer) SetHue(h *Hue)

SetHue sets the Writer's hue

func (Writer) Write

func (w Writer) Write(p []byte) (n int, err error)

Write colorizes and writes the contents of p to the underlying writer object.

func (Writer) WriteString

func (w Writer) WriteString(s string) (int, error)

WriteString colorizes and writes the string s to the underlying writer object

Jump to

Keyboard shortcuts

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