Documentation
¶
Index ¶
- Variables
- func BoolP(b bool) *bool
- func ByteP(b byte) *byte
- func CommonElements(a []string, b []string) []string
- func CompareHashAndPassword(passwordHash, password string) (bool, error)
- func CompareStringSlice(a []string, b []string) bool
- func CompareStringSliceNoOrder(a []string, b []string) bool
- func CountLines(s string) (uint, error)
- func Difference(a []string, b []string) []string
- func Dump(data interface{}) *dump
- func DurationP(d time.Duration) *time.Duration
- func EncodeSha1Hex(str string) string
- func EncodeSha256Hex(str string) string
- func ExponentialBackoff(ctx context.Context, backoff Backoff, condition ConditionFunc) error
- func ExtractPublicKey(privateKeyPEM []byte) ([]byte, error)
- func GenSSHKeyPair(bits int) ([]byte, []byte, error)
- func GoWait(wg *sync.WaitGroup, f func())
- func Int16P(i int16) *int16
- func Int32P(i int32) *int32
- func Int64P(i int64) *int64
- func Int8P(i int8) *int8
- func IntP(i int) *int
- func IsBadRequest(err error) bool
- func IsForbidden(err error) bool
- func IsInternal(err error) bool
- func IsNotExist(err error) bool
- func IsParentPath(parent, p string) bool
- func IsSameOrParentPath(parent, p string) bool
- func IsUnauthorized(err error) bool
- func Jitter(duration time.Duration, maxFactor float64) time.Duration
- func NewTLSConfig(certFile, keyFile, caFile string, insecureSkipVerify bool) (*tls.Config, error)
- func ParseGitURL(u string) (*url.URL, error)
- func PasswordHash(password string) (string, error)
- func PathHierarchy(p string) []string
- func PathList(p string) []string
- func StringInSlice(s []string, e string) bool
- func StringP(s string) *string
- func TimeP(t time.Time) *time.Time
- func Uint16P(u uint16) *uint16
- func Uint32P(u uint32) *uint32
- func Uint64P(u uint64) *uint64
- func Uint8P(u uint8) *uint8
- func UintP(u uint) *uint
- func ValidateName(s string) bool
- type Backoff
- type ConditionFunc
- type DefaultUUIDGenerator
- type ErrBadRequest
- type ErrForbidden
- type ErrGitKeyNotFound
- type ErrInternal
- type ErrNotExist
- type ErrUnauthorized
- type Errors
- type Git
- func (g *Git) ConfigGet(ctx context.Context, args ...string) (string, error)
- func (g *Git) ConfigSet(ctx context.Context, args ...string) (string, error)
- func (g *Git) Output(ctx context.Context, stdin io.Reader, args ...string) ([]byte, error)
- func (g *Git) OutputLines(ctx context.Context, stdin io.Reader, args ...string) ([]string, error)
- func (g *Git) Pipe(ctx context.Context, w io.Writer, r io.Reader, args ...string) error
- type LimitedBuffer
- type TestPrefixUUIDGenerator
- type TestUUIDGenerator
- type UUIDGenerator
Constants ¶
This section is empty.
Variables ¶
var DefaultBackoff = Backoff{ Steps: 4, Duration: 10 * time.Millisecond, Factor: 5.0, Jitter: 0.1, }
DefaultBackoff is the recommended backoff for a conflict where a client may be attempting to make an unrelated modification to a resource under active management by one or more controllers.
var DefaultRetry = Backoff{ Steps: 5, Duration: 10 * time.Millisecond, Factor: 1.0, Jitter: 0.1, }
DefaultRetry is the recommended retry for a conflict where multiple clients are making changes to the same resource.
var (
ErrValidation = errors.New("validation error")
)
var ErrWaitTimeout = errors.New("timed out waiting for the condition")
ErrWaitTimeout is returned when the condition exited without success.
var FetchFileBackoff = Backoff{ Steps: 4, Duration: 500 * time.Millisecond, Factor: 2.0, Jitter: 0.1, }
DefaultBackoff is the recommended backoff for a conflict where a client may be attempting to make an unrelated modification to a resource under active management by one or more controllers.
Functions ¶
func CommonElements ¶
CommonElements return the common elements in two slices of strings
func CompareHashAndPassword ¶
func CompareStringSlice ¶
CompareStringSlice compares two slices of strings, a nil slice is considered an empty one
func CompareStringSliceNoOrder ¶
CompareStringSliceNoOrder compares two slices of strings regardless of their order, a nil slice is considered an empty one
func CountLines ¶
func Difference ¶
Difference returns elements in a - b
func EncodeSha1Hex ¶
EncodeSha1Hex generates sha1 from string and returns its hex encoding
func EncodeSha256Hex ¶
EncodeSha1Hex generates sha1 from string and returns its hex encoding
func ExponentialBackoff ¶
func ExponentialBackoff(ctx context.Context, backoff Backoff, condition ConditionFunc) error
ExponentialBackoff repeats a condition check with exponential backoff.
It checks the condition up to Steps times, increasing the wait by multiplying the previous duration by Factor.
If Jitter is greater than zero, a random amount of each duration is added (between duration and duration*(1+jitter)).
If the condition never returns true, ErrWaitTimeout is returned. All other errors terminate immediately.
func ExtractPublicKey ¶
ExtraxtPublicKey extracts the public key from a ssh private key in pem format
func GenSSHKeyPair ¶
GenSSHKeyPair generate an ssh keypair in rsa format, returning the private key (in pem encoding) and the public key (in the OpenSSH base64 format)
func IsBadRequest ¶ added in v0.4.0
func IsForbidden ¶ added in v0.4.0
func IsInternal ¶ added in v0.4.0
func IsNotExist ¶ added in v0.4.0
func IsParentPath ¶
IsParentPath returns if the provided parent is parent of p parent and p paths must use slash "/" separators and must be absolute paths
func IsSameOrParentPath ¶
IsParentPath returns if the provided parent the same path as p or a parent of p parent and p paths must use slash "/" separators
func IsUnauthorized ¶ added in v0.4.0
func Jitter ¶
Jitter returns a time.Duration between duration and duration + maxFactor * duration.
This allows clients to avoid converging on periodic behavior. If maxFactor is 0.0, a suggested default value will be chosen.
func NewTLSConfig ¶
func PasswordHash ¶
func PathHierarchy ¶
func PathList ¶
PathList return a slice of paths from the base path (root exluded as . or / ). I.E. for a path like "path/to/file" or "/path/to/file" it'll return a slice of these elements: "path", "to", "file"
func StringInSlice ¶
func ValidateName ¶
Types ¶
type Backoff ¶
type Backoff struct { Duration time.Duration // the base duration Factor float64 // Duration is multiplied by factor each iteration Jitter float64 // The amount of jitter applied each iteration Steps int // Exit with error after this many steps }
Backoff holds parameters applied to a Backoff function.
type ConditionFunc ¶
ConditionFunc returns true if the condition is satisfied, or an error if the loop should be aborted.
type DefaultUUIDGenerator ¶
type DefaultUUIDGenerator struct{}
type ErrBadRequest ¶
type ErrBadRequest struct {
Err error
}
ErrBadRequest represent an error caused by a bad command request it's used to differentiate an internal error from an user error
func NewErrBadRequest ¶
func NewErrBadRequest(err error) *ErrBadRequest
func (*ErrBadRequest) Error ¶
func (e *ErrBadRequest) Error() string
func (*ErrBadRequest) Is ¶
func (*ErrBadRequest) Is(err error) bool
type ErrForbidden ¶
type ErrForbidden struct {
Err error
}
ErrForbidden represent an error caused by an forbidden operation it's used to differentiate an internal error from an user error
func NewErrForbidden ¶
func NewErrForbidden(err error) *ErrForbidden
func (*ErrForbidden) Error ¶
func (e *ErrForbidden) Error() string
func (*ErrForbidden) Is ¶
func (*ErrForbidden) Is(err error) bool
type ErrGitKeyNotFound ¶
type ErrGitKeyNotFound struct {
Key string
}
func (*ErrGitKeyNotFound) Error ¶
func (e *ErrGitKeyNotFound) Error() string
type ErrInternal ¶
type ErrInternal struct {
Err error
}
func NewErrInternal ¶
func NewErrInternal(err error) *ErrInternal
func (*ErrInternal) Error ¶
func (e *ErrInternal) Error() string
ErrInternal represent an internal error that should be returned to the user
func (*ErrInternal) Is ¶
func (*ErrInternal) Is(err error) bool
type ErrNotExist ¶ added in v0.4.0
type ErrNotExist struct {
Err error
}
ErrNotExist represent a not exist error it's used to differentiate an internal error from an user error
func NewErrNotExist ¶ added in v0.4.0
func NewErrNotExist(err error) *ErrNotExist
func (*ErrNotExist) Error ¶ added in v0.4.0
func (e *ErrNotExist) Error() string
func (*ErrNotExist) Is ¶ added in v0.4.0
func (*ErrNotExist) Is(err error) bool
type ErrUnauthorized ¶
type ErrUnauthorized struct {
}ErrUnauthorized represent an error caused by an unauthorized request it's used to differentiate an internal error from an user error
func NewErrUnauthorized ¶
func NewErrUnauthorized(err error) *ErrUnauthorized
func (*ErrUnauthorized) Error ¶
func (e *ErrUnauthorized) Error() string
func (*ErrUnauthorized) Is ¶
func (*ErrUnauthorized) Is(err error) bool
type Git ¶
func (*Git) OutputLines ¶
type LimitedBuffer ¶
func NewLimitedBuffer ¶
func NewLimitedBuffer(cap int) *LimitedBuffer
type TestPrefixUUIDGenerator ¶
type TestPrefixUUIDGenerator struct{ Prefix string }
type TestUUIDGenerator ¶
type TestUUIDGenerator struct{}