Documentation
¶
Index ¶
- Variables
- func AddObjectsToClientSet[C ~[]T, T runtime.Object](cli testing.FakeClient, obj C) error
- func CountLines(r io.Reader) (int, error)
- func ErrorsToStrings(errs []error) []string
- func GetAllNamespaces(ctx context.Context, coreClient corev1client.CoreV1Interface) (*corev1.NamespaceList, error)
- func GetClusterBaseDomain(ctx context.Context, configClient configv1client.ConfigV1Interface) (string, error)
- func MaxInt(values ...int) int
- func MinInt(values ...int) int
- func NestedInt64Wrapper(obj map[string]interface{}, fields ...string) (int64, error)
- func NestedSliceWrapper(obj map[string]interface{}, fields ...string) ([]interface{}, error)
- func NestedStringWrapper(obj map[string]interface{}, fields ...string) (string, error)
- func NewTestLog(t testing.TB) *log.Logger
- func ReadAllLinesWithPrefix(reader io.Reader, prefix []byte, lineFunc func(b []byte) []byte) ([]byte, error)
- func ShouldBeProcessedNow(lastProcessingTime time.Time, period time.Duration) bool
- func SortAndRemoveDuplicates(slicePtr interface{}, less func(i, j int) bool)
- func StringInSlice(str string, slice []string) bool
- func StructToMap(obj interface{}) (map[string]interface{}, error)
- func TakeLastNItemsFromByteArray(array []byte, desiredLength int) []byte
- func UniqueErrors(errs []error) error
- func UniqueStrings(list []string) []string
- type LineLimitedReader
Constants ¶
This section is empty.
Variables ¶
var ( // MetricsLineSep is the line separator used by the alerts metric MetricsLineSep = []byte{'\n'} )
Functions ¶
func AddObjectsToClientSet ¶
func AddObjectsToClientSet[C ~[]T, T runtime.Object](cli testing.FakeClient, obj C) error
func CountLines ¶
CountLines reads the remainder of the reader and counts the number of lines.
Inspired by: https://stackoverflow.com/a/24563853/
func ErrorsToStrings ¶
ErrorsToStrings turns error slice to string slice
func GetAllNamespaces ¶
func GetAllNamespaces(ctx context.Context, coreClient corev1client.CoreV1Interface) (*corev1.NamespaceList, error)
func GetClusterBaseDomain ¶
func GetClusterBaseDomain(ctx context.Context, configClient configv1client.ConfigV1Interface) (string, error)
GetClusterBaseDomain returns a base domain for the cluster. Base domain is the base domain of the cluster. All managed DNS records will be subdomains of this base.
For example, given the base domain `openshift.example.com`, an API server DNS record may be created for `cluster-api.openshift.example.com`.
It uses this API https://docs.openshift.com/container-platform/4.7/rest_api/config_apis/dns-config-openshift-io-v1.html
func NestedInt64Wrapper ¶
func NestedSliceWrapper ¶
func NestedStringWrapper ¶
func ReadAllLinesWithPrefix ¶
func ReadAllLinesWithPrefix(reader io.Reader, prefix []byte, lineFunc func(b []byte) []byte) ([]byte, error)
ReadAllLinesWithPrefix reads lines from the given reader and returns those that begin with the specified prefix.
func ShouldBeProcessedNow ¶
ShouldBeProcessedNow useful function for gatherers with custom period
func SortAndRemoveDuplicates ¶
SortAndRemoveDuplicates sorts the slice pointed by the provided pointer given the provided less function and removes repeated elements. The function panics if the provided interface is not a pointer to a slice.
func StringInSlice ¶
StringInSlice simply checks if the string is present in slice
func StructToMap ¶
func TakeLastNItemsFromByteArray ¶
TakeLastNItemsFromByteArray takes last N items from provided byte array or adds zeros to the beginning if there not enough space
func UniqueErrors ¶
UniqueErrors filters out the duplicates in the input slice of errors and returns a single error when the error strings are joined by comma character
func UniqueStrings ¶
UniqueStrings returns a new string slice where each element exists maximum once, the order of items is preserved (e.g. [9, 4, 9, 8, 1, 2, 2, 4, 3] becomes [9, 4, 8, 1, 2, 3])
Types ¶
type LineLimitedReader ¶
type LineLimitedReader struct {
// contains filtered or unexported fields
}
A LineLimitedReader reads from R but limits the amount of data returned to just N lines. Each call to Read updates N to reflect the new amount remaining. Read returns EOF when N <= 0 or when the underlying R returns EOF.
func NewLineLimitReader ¶
func NewLineLimitReader(r io.Reader, n int) *LineLimitedReader
NewLineLimitReader returns a Reader that reads from `r` but stops with EOF after `n` lines.
func (*LineLimitedReader) GetTotalLinesRead ¶
func (l *LineLimitedReader) GetTotalLinesRead() int
GetTotalLinesRead return the total number of line separators already read by the underlying reader. This includes lines that have been truncated by the `Read` calls after exceeding the line limit.