Documentation ¶
Index ¶
- Constants
- Variables
- func BuildArchive(ctx context.Context, tarWriter *tar.Writer, rootPath string, includes []string, ...) (int, error)
- func BuildFileList(startPath string, expressions ...string) ([]string, error)
- func CalculateHMACHash(secret []byte, body []byte) (string, error)
- func CleanForPath(name string) string
- func CleanName(name string) string
- func DeepCopy(src, copy interface{}, registeredTypes []interface{}) error
- func EscapeJQLReservedChars(in string) string
- func ExpandValues(input interface{}, expansions *Expansions) error
- func ExtractTarball(ctx context.Context, reader io.Reader, rootPath string, excludes []string) error
- func FileExists(path string) (bool, error)
- func FromNanoseconds(duration time.Duration) int64
- func FromPythonTime(pyTime float64) time.Time
- func GetBoolValue(r *http.Request, valueKey string, defaultValue bool) (bool, error)
- func GetHTTPClient() *http.Client
- func GetIntValue(r *http.Request, valueKey string, defaultValue int) (int, error)
- func GetOAuth2HTTPClient(oauthToken string) (*http.Client, error)
- func GetPprofApp() *gimlet.APIApp
- func GetRetryableOauth2HTTPClient(oauthToken string, fRetry rehttp.RetryFn, fDelay rehttp.DelayFn) (*http.Client, error)
- func GetStringArrayValue(r *http.Request, valueKey string, defaultValue []string) []string
- func IndexWhiteSpace(s string) int
- func IsExpandable(param string) bool
- func IsFiniteNumericFloat(f float64) bool
- func IsZeroTime(t time.Time) bool
- func JitterInterval(interval time.Duration) time.Duration
- func Min(a ...int) int
- func NewEvergreenWebhookLogger() (send.Sender, error)
- func NewRequestReader(req *http.Request) io.ReadCloser
- func NewRequestReaderWithSize(req *http.Request, size int64) io.ReadCloser
- func NewResponseReader(req *http.Response) io.ReadCloser
- func NewResponseReaderWithSize(req *http.Response, size int64) io.ReadCloser
- func NewWebhookMessage(id string, url string, secret []byte, body []byte, headers map[string][]string) message.Composer
- func NewWebhookMessageWithStruct(raw EvergreenWebhook) message.Composer
- func PutHTTPClient(c *http.Client)
- func RandomString() string
- func ReadFromYAMLFile(fn string, data interface{}) error
- func ReadJSONInto(r io.ReadCloser, data interface{}) error
- func ReadJSONIntoWithLength(r io.ReadCloser, data interface{}) (int, error)
- func ReadYAMLInto(r io.ReadCloser, data interface{}) error
- func RehttpDelay(initialSleep time.Duration, numAttempts int) rehttp.DelayFn
- func Retry(op RetriableFunc, attempts int, sleep time.Duration) (bool, error)
- func RoundPartOfHour(num int) time.Time
- func RoundPartOfMinute(num int) time.Time
- func StringSliceContains(slice []string, item string) bool
- func StringSliceIntersection(a, b []string) []string
- func TarGzReader(path string) (f, gz io.ReadCloser, tarReader *tar.Reader, err error)
- func TarGzWriter(path string) (f, gz io.WriteCloser, tarWriter *tar.Writer, err error)
- func ToNanoseconds(duration time.Duration) time.Duration
- func ToPythonTime(t time.Time) float64
- func Truncate(input string, outputLength int) string
- func TryParseFloat(s string) (float64, error)
- func UniqueStrings(slice []string) []string
- func WriteCSVResponse(w http.ResponseWriter, status int, data interface{})
- func WriteJSONInto(fn string, data interface{}) error
- func WriteTempFile(prefix string, data []byte) (string, error)
- func WriteToFile(body io.ReadCloser, filepath string) error
- func WriteToTempFile(data string) (string, error)
- type ArchiveContentFile
- type CachedDurationValue
- type CachedDurationValueRefresher
- type CachedIntValue
- type CachedIntValueRefresher
- type CappedWriter
- type EvergreenWebhook
- type Expansions
- func (self *Expansions) Exists(expansion string) bool
- func (self *Expansions) ExpandString(toExpand string) (string, error)
- func (self *Expansions) Get(expansion string) string
- func (self *Expansions) Map() map[string]string
- func (self *Expansions) Put(expansion string, value string)
- func (self *Expansions) Update(newItems map[string]string)
- func (self *Expansions) UpdateFromYaml(filename string) error
- type KeyValuePair
- type KeyValuePairSlice
- type RetriableFunc
- type SafeCounter
- type StaticHostInfo
- type StringOrBool
Constants ¶
const (
DefaultSSHPort = "22"
)
Variables ¶
var ErrBufferFull = errors.New("buffer full")
ErrBufferFull indicates that a CappedWriter's bytes.Buffer has MaxBytes bytes.
var ZeroTime time.Time = time.Unix(0, 0)
ZeroTime represents 0 in epoch time
Functions ¶
func BuildArchive ¶
func BuildArchive(ctx context.Context, tarWriter *tar.Writer, rootPath string, includes []string, excludes []string, logger grip.Journaler) (int, error)
BuildArchive reads the rootPath directory into the tar.Writer, taking included and excluded strings into account. Returns the number of files that were added to the archive
func BuildFileList ¶
BuildFileList returns a list of files that match the given list of expressions rooted at the given startPath. The expressions correspond to gitignore ignore expressions: anything that would be matched - and therefore ignored by git - is included in the returned list of file paths. BuildFileList does not follow symlinks as it uses filpath.Walk, which does not follow symlinks.
func CalculateHMACHash ¶
CalculateHMACHash calculates a sha256 HMAC has of the body with the given secret. The body must NOT be modified after calculating this hash. The string result will be prefixed with "sha256=", followed by the HMAC hash. When validating this hash, use a constant-time compare to avoid vulnerability to timing attacks.
func CleanForPath ¶
func DeepCopy ¶
func DeepCopy(src, copy interface{}, registeredTypes []interface{}) error
DeepCopy makes a deep copy of the src value into the copy params The registeredTypes param can be optionally used to register additional types that need to be used by gob
func EscapeJQLReservedChars ¶
see https://confluence.atlassian.com/jiracoreserver073/search-syntax-for-text-fields-861257223.html
func ExpandValues ¶
func ExpandValues(input interface{}, expansions *Expansions) error
Taking in the input and expansions map, apply the expansions to any appropriate fields in the input. The input must be a pointer to a struct so that the underlying struct can be modified.
func ExtractTarball ¶
func FileExists ¶
FileExists returns true if 'path' exists.
func FromNanoseconds ¶
fromNanoSeconds returns milliseconds of a duration for queries in the database.
func FromPythonTime ¶
FromPythonTime returns a time.Time that corresponds to the float style python time which is <seconds>.<fractional_seconds> from unix epoch.
func GetBoolValue ¶
GetBoolValue returns a form value as an integer
func GetHTTPClient ¶
func GetIntValue ¶
GetIntValue returns a form value as an integer
func GetPprofApp ¶
func GetStringArrayValue ¶
GetStringArrayValue returns a form value as a string array
func IndexWhiteSpace ¶
IndexWhiteSpace returns the first index of white space in the given string. Returns -1 if no white space exists.
func IsExpandable ¶
IsExpandable returns true if the passed in string contains an expandable parameter
func IsFiniteNumericFloat ¶
IsFiniteNumericFloat takes a float64 and checks that it is not +inf, -inf, or NaN
func IsZeroTime ¶
IsZeroTime checks that a time is either equal to golang ZeroTime or UTC ZeroTime.
func JitterInterval ¶
JitterInterval returns a duration that some value between the interval and 2x the interval.
func NewRequestReader ¶
func NewRequestReader(req *http.Request) io.ReadCloser
NewRequestReader returns an io.ReadCloser closer for the body of an *http.Request, using a limited reader internally to avoid unbounded reading from the request body. The reader is limited to 16 megabytes.
func NewRequestReaderWithSize ¶
func NewRequestReaderWithSize(req *http.Request, size int64) io.ReadCloser
NewRequestReaderWithSize returns an io.ReadCloser closer for the body of an *http.Request with a user-specified size.
func NewResponseReader ¶
func NewResponseReader(req *http.Response) io.ReadCloser
NewResponseReader returns an io.ReadCloser closer for the body of an *http.Response, using a limited reader internally to avoid unbounded reading from the request body. The reader is limited to 16 megabytes.
func NewResponseReaderWithSize ¶
func NewResponseReaderWithSize(req *http.Response, size int64) io.ReadCloser
NewResponseReaderWithSize returns an io.ReadCloser closer for the body of an *http.Response with a user-specified size.
func NewWebhookMessage ¶
func NewWebhookMessageWithStruct ¶
func NewWebhookMessageWithStruct(raw EvergreenWebhook) message.Composer
func PutHTTPClient ¶
func RandomString ¶
func RandomString() string
RandomString returns a cryptographically random string.
func ReadFromYAMLFile ¶
func ReadJSONInto ¶
func ReadJSONInto(r io.ReadCloser, data interface{}) error
ReadJSONInto reads JSON from an io.ReadCloser into the data pointer.
func ReadJSONIntoWithLength ¶
func ReadJSONIntoWithLength(r io.ReadCloser, data interface{}) (int, error)
ReadJSONInto reads JSON from an io.ReadCloser into the data pointer.
func ReadYAMLInto ¶
func ReadYAMLInto(r io.ReadCloser, data interface{}) error
ReadYAMLInto reads data for the given io.ReadCloser - until it hits an error or reaches EOF - and attempts to unmarshal the data read into the given interface.
func Retry ¶
Retry provides a mechanism to retry an operation with exponential backoff (that uses some jitter,) Specify the maximum number of retry attempts that you want to permit as well as the initial period that you want to sleep between attempts.
Retry requires that the starting sleep interval be at least 100 milliseconds, and forces this interval if you attempt to use a shorter period.
If you specify 0 attempts, Retry will use an attempt value of one.
func RoundPartOfHour ¶
ParseRoundPartOfHour produces a time value with the minute value rounded down to the most recent interval.
func RoundPartOfMinute ¶
ParseRoundPartOfMinute produces a time value with the second value rounded down to the most recent interval.
func StringSliceContains ¶
StringSliceContains determines if a string is in a slice
func StringSliceIntersection ¶
StringSliceIntersection returns the intersecting elements of slices a and b.
func TarGzReader ¶
TarGzReader returns a file, gzip reader, and tar reader for the given path. The tar reader wraps the gzip reader, which wraps the file.
func TarGzWriter ¶
TarGzWriter returns a file, gzip writer, and tarWriter for the path. The tar writer wraps the gzip writer, which wraps the file.
func ToNanoseconds ¶
fromNanoSeconds returns milliseconds of a duration for queries in the database.
func ToPythonTime ¶
ToPythonTime returns a number in the format that python's time.time() returns as a float with <seconds>.<fractional_seconds>
func TryParseFloat ¶
TryParseFloat takes an input string and validates that it is a valid finite floating point number. The number is returned if valid, NaN if not
func UniqueStrings ¶
UniqueStrings takes a slice of strings and returns a new slice with duplicates removed. Order is preserved.
func WriteCSVResponse ¶
func WriteCSVResponse(w http.ResponseWriter, status int, data interface{})
WriteToCSVResponse takes in an interface that is a slice or an array and converts the struct to csv for fields that have the the csv struct tag.
func WriteJSONInto ¶
func WriteTempFile ¶
WriteTempFile creates a temp file, writes the data to it, closes it and returns the file name.
func WriteToFile ¶
func WriteToFile(body io.ReadCloser, filepath string) error
WriteToFile takes in a body and filepath and writes out the data in the body
func WriteToTempFile ¶
WriteToTempFile writes the given string to a temporary file and returns the path to the file.
Types ¶
type ArchiveContentFile ¶
type ArchiveContentFile struct { Path string Info os.FileInfo // contains filtered or unexported fields }
ArchiveContentFile represents a tar file on disk.
func FindContentsToArchive ¶
type CachedDurationValue ¶
type CachedDurationValue struct { Value time.Duration `bson:"value"` TTL time.Duration `bson:"ttl"` CollectedAt time.Time `bson:"collected_at"` // contains filtered or unexported fields }
CachedDurationValue represents a calculated int value saved in a database with a expiration time. When the data is not expired, the value is returned directly by the Get() method, otherwise, a refresh function is called, to update the value.
func NewCachedDurationValue ¶
func NewCachedDurationValue(start, ttl time.Duration, refresh CachedDurationValueRefresher) *CachedDurationValue
NewCachedDurationValue constructs a CachedDurationValue object.
func (*CachedDurationValue) Get ¶
func (v *CachedDurationValue) Get() (time.Duration, bool)
Get returns the value, refreshing it when its stale. The "ok" value reports errors with the refresh process and alerts callers that the value might be stale.
func (*CachedDurationValue) SetRefresher ¶
func (v *CachedDurationValue) SetRefresher(r CachedDurationValueRefresher) error
SetRefresher sets CachedDurationValueRefresher for the object which is needed when reading CachedDurationValue objects out of the database.
It is not permissible to set the refresher to either nil or a value when it is *not* nil.
func (*CachedDurationValue) String ¶
func (v *CachedDurationValue) String() string
String implements fmt.Stringer reporting how stale the value is in the stale case.
type CachedDurationValueRefresher ¶
CachedDurationValueRefresher provides a mechanism for CachedDurationValues to update their values when the current cached value expires. Implementations are responsible for logging errors, as needed.
type CachedIntValue ¶
type CachedIntValue struct { Value int `bson:"value"` TTL time.Duration `bson:"ttl"` CollectedAt time.Time `bson:"collected_at"` // contains filtered or unexported fields }
CachedIntValue represents a calculated int value saved in a database with a expiration time. When the data is not expired, the value is returned directly by the Get() method, otherwise, a refresh function is called, to update the value.
func NewCachedIntValue ¶
func NewCachedIntValue(start int, ttl time.Duration, refresh CachedIntValueRefresher) *CachedIntValue
NewCachedIntValue constructs a CachedIntValue object.
func (*CachedIntValue) Get ¶
func (v *CachedIntValue) Get() (int, bool)
Get returns the value, refreshing it when its stale. The "ok" value reports errors with the refresh process and alerts callers that the value might be stale.
func (*CachedIntValue) SetRefresher ¶
func (v *CachedIntValue) SetRefresher(r CachedIntValueRefresher) error
SetRefresher sets CachedIntValueRefresher for the object which is needed when reading CachedIntValue objects out of the database.
It is not permissible to set the refresher to either nil or a value when it is *not* nil.
func (*CachedIntValue) String ¶
func (v *CachedIntValue) String() string
String implements fmt.Stringer reporting how stale the value is in the stale case.
type CachedIntValueRefresher ¶
CachedIntValueRefresher provides a mechanism for CachedIntValues to update their values when the current cached value expires. Implementations are responsible for logging errors, as needed.
type CappedWriter ¶
CappedWriter implements a buffer that stores up to MaxBytes bytes. Returns ErrBufferFull on overflowing writes
func (*CappedWriter) IsFull ¶
func (cw *CappedWriter) IsFull() bool
IsFull indicates whether the buffer is full.
func (*CappedWriter) String ¶
func (cw *CappedWriter) String() string
String return the contents of the buffer as a string.
type EvergreenWebhook ¶
type Expansions ¶
Wrapper for an expansions map, with some utility functions.
func NewExpansions ¶
func NewExpansions(initMap map[string]string) *Expansions
Return a new Expansions object with all of the specified expansions present.
func (*Expansions) Exists ¶
func (self *Expansions) Exists(expansion string) bool
Check if a value is present in the expansions.
func (*Expansions) ExpandString ¶
func (self *Expansions) ExpandString(toExpand string) (string, error)
Apply the expansions to a single string. Return the expanded string, or an error if the input string is malformed.
func (*Expansions) Get ¶
func (self *Expansions) Get(expansion string) string
Get a single value from the expansions. Return the value, or the empty string if the value is not present.
func (*Expansions) Map ¶
func (self *Expansions) Map() map[string]string
func (*Expansions) Put ¶
func (self *Expansions) Put(expansion string, value string)
Set a single value in the expansions.
func (*Expansions) Update ¶
func (self *Expansions) Update(newItems map[string]string)
Update all of the specified keys in the expansions to point to the specified values.
func (*Expansions) UpdateFromYaml ¶
func (self *Expansions) UpdateFromYaml(filename string) error
Read a map of keys/values from the given file, and update the expansions to include them (overwriting any duplicates with the new value).
type KeyValuePair ¶
type KeyValuePair struct { Key string `bson:"key" json:"key" yaml:"key"` Value interface{} `bson:"value" json:"value" yaml:"value"` }
type KeyValuePairSlice ¶
type KeyValuePairSlice []KeyValuePair
func MakeKeyValuePair ¶
func MakeKeyValuePair(in map[string]string) KeyValuePairSlice
func MakeNestedKeyValuePair ¶
func MakeNestedKeyValuePair(in map[string]map[string]string) KeyValuePairSlice
type RetriableFunc ¶
RetriableFunc is any function that takes no parameters and returns only an error interface. These functions can be used with util.Retry.
type SafeCounter ¶
type SafeCounter struct {
// contains filtered or unexported fields
}
func (*SafeCounter) Inc ¶
func (s *SafeCounter) Inc()
func (*SafeCounter) String ¶
func (s *SafeCounter) String() string
func (*SafeCounter) Value ¶
func (s *SafeCounter) Value() int
type StaticHostInfo ¶
StaticHostInfo stores the connection parameters for connecting to an SSH host.
func ParseSSHInfo ¶
func ParseSSHInfo(fullHostname string) (*StaticHostInfo, error)
ParseSSHInfo reads in a hostname definition and reads the relevant SSH connection information from it. For example,
"admin@myhostaddress:24"
will return
StaticHostInfo{User: "admin", Hostname:"myhostaddress", Port: 24}
type StringOrBool ¶
type StringOrBool string
func (*StringOrBool) Bool ¶
func (v *StringOrBool) Bool() (bool, error)
func (*StringOrBool) MarshalJSON ¶
func (v *StringOrBool) MarshalJSON() ([]byte, error)
func (*StringOrBool) MarshalYAML ¶
func (v *StringOrBool) MarshalYAML() (interface{}, error)
func (*StringOrBool) UnmarshalJSON ¶
func (v *StringOrBool) UnmarshalJSON(in []byte) error
func (*StringOrBool) UnmarshalYAML ¶
func (v *StringOrBool) UnmarshalYAML(um func(interface{}) error) error
Source Files ¶
- artifacts.go
- artifacts_tar.go
- cached_value.go
- capped_writer.go
- copy.go
- counter.go
- csv.go
- expand_params.go
- expansion.go
- file.go
- hmac_hash.go
- http.go
- http_client_pool.go
- http_pprof.go
- io.go
- json.go
- key_val_pair.go
- limited_reader.go
- math.go
- random.go
- retry.go
- slice.go
- ssh.go
- strings.go
- time.go
- type_string_or_bool.go
- webhook_grip.go
- yaml.go