common

package
v0.0.0-...-7320257 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var YamlStringTransformer = cmp.Transformer("YamlLines", func(s YamlString) []string {

	lines := strings.Split(string(s), "\n")

	// Remove any empty lines from the start and end.
	var start, end int
	for i := range lines {
		if lines[i] != "" {
			start = i
			break
		}
	}
	for i := len(lines) - 1; i >= 0; i-- {
		if lines[i] != "" {
			end = i
			break
		}
	}
	return lines[start : end+1]
})

YamlStringTransformer transforms a YamlString into a slice of strings by splitting on each new line. This allows the diffing function (used in tests) to compare each line independently. The result is that the diff output marks each line where a diff was observed.

Functions

func PtrTo

func PtrTo[T any](a T) *T

Types

type K8sClients

type K8sClients struct {
	Client          client.Client
	DC              dynamic.Interface
	DiscoveryClient discovery.DiscoveryInterface
}

func MustClientsForTest

func MustClientsForTest(t *testing.T, initRuntimeObjects ...runtime.Object) *K8sClients

func NewK8sClients

func NewK8sClients(kubeconfig string) (*K8sClients, error)

type YamlString

type YamlString string

YamlString defines a custom type for wrapping yaml texts. It makes use of YamlStringTransformer to generate slightly better diffing output from cmp.Diff() for multi-line yaml texts.

Jump to

Keyboard shortcuts

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