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 NamespaceForTest ¶
Types ¶
type JSONString ¶
type JSONString string
func (JSONString) CmpDiff ¶
func (src JSONString) CmpDiff(tgt JSONString) (diff string, err error)
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 ObjRef ¶
type ObjRef struct { Group string `json:",omitempty"` Kind string `json:",omitempty"` Name string `json:",omitempty"` Namespace string `json:",omitempty"` }
ObjRef defines a reference to a Kubernetes resource, using plain strings for easier comparison.
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.
Click to show internal directories.
Click to hide internal directories.