testing

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TrackerKey key = struct{}{}

TrackerKey is used to looking a FakeTracker in a context.Context

Functions

func AssertTrackingConfigMap added in v0.6.0

func AssertTrackingConfigMap(namespace, name string) func(*testing.T, *reconcilertesting.TableRow)

AssertTrackingConfigMap will ensure the provided ConfigMap is being tracked

func AssertTrackingObject

func AssertTrackingObject(gvk schema.GroupVersionKind, namespace, name string) func(*testing.T, *reconcilertesting.TableRow)

AssertTrackingObject will ensure the following objects are being tracked

func AssertTrackingSecret

func AssertTrackingSecret(namespace, name string) func(*testing.T, *reconcilertesting.TableRow)

AssertTrackingSecret will ensure the provided Secret is being tracked

func MakeFactory

func MakeFactory(ctor Ctor, unstructured bool, logger *zap.SugaredLogger, privKMSKey *ecdsa.PrivateKey) reconcilertesting.Factory

MakeFactory creates a reconciler factory with fake clients and controller created by `ctor`.

func NewClusterImagePolicy

func NewClusterImagePolicy(name string, o ...ClusterImagePolicyOption) *v1alpha1.ClusterImagePolicy

NewClusterImagePolicy creates a ClusterImagePolicy with ClusterImagePolicyOptions.

func NewScheme

func NewScheme() *runtime.Scheme

func NewTrustRoot added in v0.6.0

func NewTrustRoot(name string, o ...TrustRootOption) *v1alpha1.TrustRoot

NewTrustRoot creates a TrustRoot with TrustRootOptions.

func ToUnstructured

func ToUnstructured(t *testing.T, objs []runtime.Object) (us []runtime.Object)

ToUnstructured takes a list of k8s resources and converts them to Unstructured objects. We must pass objects as Unstructured to the dynamic client fake, or it won't handle them properly.

func WithClusterImagePolicyDeletionTimestamp

func WithClusterImagePolicyDeletionTimestamp(cip *v1alpha1.ClusterImagePolicy)

func WithFinalizer

func WithFinalizer(cip *v1alpha1.ClusterImagePolicy)

func WithTrustRootDeletionTimestamp added in v0.6.0

func WithTrustRootDeletionTimestamp(tk *v1alpha1.TrustRoot)

func WithTrustRootFinalizer added in v0.6.0

func WithTrustRootFinalizer(tk *v1alpha1.TrustRoot)

Types

type ClusterImagePolicyOption

type ClusterImagePolicyOption func(*v1alpha1.ClusterImagePolicy)

ClusterImagePolicyOption enables further configuration of a ClusterImagePolicy.

func WithMatch added in v0.4.0

func WithMode added in v0.3.0

func WithMode(m string) ClusterImagePolicyOption

func WithPolicy added in v0.6.0

func WithResourceVersion added in v0.4.0

func WithResourceVersion(resourceVersion string) ClusterImagePolicyOption

func WithUID added in v0.4.0

func WithUID(uid string) ClusterImagePolicyOption

type Ctor

Ctor functions create a k8s controller with given params.

type Listers

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

func NewListers

func NewListers(objs []runtime.Object) Listers

func (*Listers) GetAllObjects

func (l *Listers) GetAllObjects() []runtime.Object

func (*Listers) GetClusterImagePolicyLister

func (l *Listers) GetClusterImagePolicyLister() policylisters.ClusterImagePolicyLister

func (*Listers) GetConfigMapLister

func (l *Listers) GetConfigMapLister() corev1listers.ConfigMapLister

func (*Listers) GetCosignObjects

func (l *Listers) GetCosignObjects() []runtime.Object

func (*Listers) GetKubeObjects

func (l *Listers) GetKubeObjects() []runtime.Object

func (*Listers) GetSecretLister

func (l *Listers) GetSecretLister() corev1listers.SecretLister

func (*Listers) GetTrustRootLister added in v0.6.0

func (l *Listers) GetTrustRootLister() policylisters.TrustRootLister

type TrustRootOption added in v0.6.0

type TrustRootOption func(*v1alpha1.TrustRoot)

TrustRootOption enables further configuration of a ClusterImagePolicy.

func WithRepository added in v0.6.0

func WithRepository(targets string, root, repository []byte) TrustRootOption

WithRepository constructs a TrustRootOption which is suitable for reconciler table driven testing.

func WithSigstoreKeys added in v0.6.0

func WithSigstoreKeys(sk map[string]string) TrustRootOption

WithSigstoreKeys constructs a TrustRootOption which is suitable for reconciler table driven testing. It hardcodes things like organizations/common names, and URI/BaseURLs with predictable values.

func WithTrustRootResourceVersion added in v0.6.0

func WithTrustRootResourceVersion(resourceVersion string) TrustRootOption

func WithTrustRootUID added in v0.6.0

func WithTrustRootUID(uid string) TrustRootOption

Jump to

Keyboard shortcuts

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