util

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelToSnake added in v0.22.9

func CamelToSnake(str string) string

CamelToSnake is a helper function for converting CamelCase to Snake Case

func CompareYAML added in v0.14.0

func CompareYAML(a, b interface{}) bool

CompareYAML marshals a and b to YAML and ensures that their contents are equal. If either Marshal fails, CompareYAML returns false.

func DefaultConfigFromFlags

func DefaultConfigFromFlags(cfg interface{}) interface{}

DefaultConfigFromFlags will load default values into cfg by retrieving default values that are registered as flags.

cfg must implement either PrefixedConfigFlags or ConfigFlags.

func MarshalYAMLMerged added in v0.22.0

func MarshalYAMLMerged(vv ...interface{}) ([]byte, error)

MarshalYAMLMerged marshals all values from vv into a single object.

func TestLogger added in v0.14.0

func TestLogger(t *testing.T) log.Logger

TestLogger generates a logger for a test.

func UnmarshalYAMLMerged added in v0.22.0

func UnmarshalYAMLMerged(bb []byte, vv ...interface{}) error

UnmarshalYAMLMerged performs a strict unmarshal of bb into all values from vv.

func Untab added in v0.13.0

func Untab(s string) string

Untab is a utility function for tests to make it easier to write YAML tests, where some editors will insert tabs into strings by default.

Types

type ConfigFlags

type ConfigFlags interface {
	RegisterFlags(f *flag.FlagSet)
}

ConfigFlags is an interface that will register flags that can control some object.

type PrefixedConfigFlags

type PrefixedConfigFlags interface {
	RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)
}

PrefixedConfigFlags is an interface that, given a prefix for flags and a flagset, will register flags that can control some object.

type RawYAML added in v0.22.0

type RawYAML []byte

RawYAML is similar to json.RawMessage and allows for deferred YAML decoding.

func (RawYAML) Map added in v0.22.0

func (r RawYAML) Map() (yaml.MapSlice, error)

Map converts the raw YAML into a yaml.MapSlice.

func (RawYAML) MarshalYAML added in v0.22.0

func (r RawYAML) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*RawYAML) UnmarshalYAML added in v0.22.0

func (r *RawYAML) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Unregisterer added in v0.13.0

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

Unregisterer is a Prometheus Registerer that can unregister all collectors passed to it.

func WrapWithUnregisterer added in v0.13.0

func WrapWithUnregisterer(reg prometheus.Registerer) *Unregisterer

WrapWithUnregisterer wraps a prometheus Registerer with capabilities to unregister all collectors.

func (*Unregisterer) MustRegister added in v0.13.0

func (u *Unregisterer) MustRegister(cs ...prometheus.Collector)

MustRegister implements prometheus.Registerer.

func (*Unregisterer) Register added in v0.13.0

func (u *Unregisterer) Register(c prometheus.Collector) error

Register implements prometheus.Registerer.

func (*Unregisterer) Unregister added in v0.13.0

func (u *Unregisterer) Unregister(c prometheus.Collector) bool

Unregister implements prometheus.Registerer.

func (*Unregisterer) UnregisterAll added in v0.13.0

func (u *Unregisterer) UnregisterAll() bool

UnregisterAll unregisters all collectors that were registered through the Reigsterer.

type WaitTrigger added in v0.22.0

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

WaitTrigger allows for waiting for a specific condition to be met. Useful for tests.

func NewWaitTrigger added in v0.22.0

func NewWaitTrigger() *WaitTrigger

NewWaitTrigger creates a new WaitTrigger.

func (*WaitTrigger) Trigger added in v0.22.0

func (wt *WaitTrigger) Trigger()

Trigger completes the trigger and alerts all waiting. Calling Trigger again after the first invocation is a no-op.

func (*WaitTrigger) Wait added in v0.22.0

func (wt *WaitTrigger) Wait(timeout time.Duration) error

Wait waits for trigger to complete up to the specified timeout. Returns an error if the timeout expires.

func (*WaitTrigger) WaitContext added in v0.22.9

func (wt *WaitTrigger) WaitContext(ctx context.Context) error

WaitContext waits for trigger to complete or for the context to cancel. Returns an error if ctx gets canceled.

Directories

Path Synopsis
Package k8s spins up a Kubernetes cluster for testing.
Package k8s spins up a Kubernetes cluster for testing.
Package structwalk allows you to "walk" the hierarchy of a struct.
Package structwalk allows you to "walk" the hierarchy of a struct.
Package subset implements functions to check if one value is a subset of another.
Package subset implements functions to check if one value is a subset of another.

Jump to

Keyboard shortcuts

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