common

package
v0.0.0-...-d8d23c1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GatewayClassGK   schema.GroupKind = schema.GroupKind{Group: gatewayv1.GroupName, Kind: "GatewayClass"}
	GatewayGK        schema.GroupKind = schema.GroupKind{Group: gatewayv1.GroupName, Kind: "Gateway"}
	HTTPRouteGK      schema.GroupKind = schema.GroupKind{Group: gatewayv1.GroupName, Kind: "HTTPRoute"}
	NamespaceGK      schema.GroupKind = schema.GroupKind{Group: corev1.GroupName, Kind: "Namespace"}
	ServiceGK        schema.GroupKind = schema.GroupKind{Group: corev1.GroupName, Kind: "Service"}
	ReferenceGrantGK schema.GroupKind = schema.GroupKind{Group: gatewayv1beta1.GroupName, Kind: "ReferenceGrant"}
	PolicyGK         schema.GroupKind = schema.GroupKind{Group: gwctlPolicyGroup, Kind: "Policy"}
	PolicyCRDGK      schema.GroupKind = schema.GroupKind{Group: gwctlPolicyGroup, Kind: "PolicyCRD"}
)
View Source
var MultiLineTransformer = cmp.Transformer("MultiLine", func(m MultiLine) []string {
	return strings.Split(string(m), "\n")
})

MultiLineTransformer transforms a MultiLine 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 MustPrettyPrint

func MustPrettyPrint(data any)

func NamespaceForTest

func NamespaceForTest(name string) *corev1.Namespace

func NewDefaultGroupKindFetcher

func NewDefaultGroupKindFetcher(factory Factory, options ...groupKindFetcherOption) *defaultGroupKindFetcher

func WithAdditionalResources

func WithAdditionalResources(resources []*unstructured.Unstructured) groupKindFetcherOption

Types

type Factory

type Factory interface {
	NewBuilder() *resource.Builder
	KubeConfigNamespace() (string, bool, error)
}

func NewFactory

func NewFactory(clientGetter genericclioptions.RESTClientGetter) Factory

type GKNN

type GKNN struct {
	Group     string `json:",omitempty"`
	Kind      string `json:",omitempty"`
	Namespace string `json:",omitempty"`
	Name      string `json:",omitempty"`
}

func GKNNFromUnstructured

func GKNNFromUnstructured(u *unstructured.Unstructured) GKNN

func (GKNN) GroupKind

func (g GKNN) GroupKind() schema.GroupKind

func (GKNN) MarshalText

func (g GKNN) MarshalText() ([]byte, error)

func (GKNN) NamespacedName

func (g GKNN) NamespacedName() types.NamespacedName

func (GKNN) String

func (g GKNN) String() string

type GroupKindFetcher

type GroupKindFetcher interface {
	Fetch(gk schema.GroupKind) ([]*unstructured.Unstructured, error)
}

type JSONString

type JSONString string

func (JSONString) CmpDiff

func (src JSONString) CmpDiff(tgt JSONString) (diff string, err error)

type MultiLine

type MultiLine string

MultiLine defines a custom type for wrapping texts spanning multilpe lines. It makes use of MultiLineTransformer to generate slightly better diffing output from cmp.Diff() for multi-line texts.

func (MultiLine) String

func (m MultiLine) String() string

type ReferenceFromTo

type ReferenceFromTo struct {
	// ReferringObject is the "from" object which is referring "to" some other
	// object.
	ReferringObject GKNN
	// ReferredObject is the actual object which is being referenced by another
	// object.
	ReferredObject GKNN
}

type ReferenceNotPermittedError

type ReferenceNotPermittedError struct {
	ReferenceFromTo
}

func (ReferenceNotPermittedError) Error

type ReferenceToNonExistentResourceError

type ReferenceToNonExistentResourceError struct {
	ReferenceFromTo
}

func (ReferenceToNonExistentResourceError) Error

Jump to

Keyboard shortcuts

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