testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides shared test helpers for building bootc CRD objects with functional options. It's used by both envtests and e2e tests.

Index

Constants

View Source
const (
	ImageRepo = "quay.io/example/myos"

	ImageTaggedRef = ImageRepo + ":latest"

	DigestA = "sha256:06f961b802bc46ee168555f066d28f4f0e9afdf3f88174c1ee6f9de004fc30a0"
	DigestB = "sha256:c0cde77fa8fef97d476c10aad3d2d54fcc2f336140d073651c2dcccf1e379fd6"
	DigestC = "sha256:12f37a8a84034d3e623d726fe10e5031f4df997ac13f4d5571b5a90c41fb84fe"

	ImageDigestRefA = ImageRepo + "@" + DigestA
	ImageDigestRefB = ImageRepo + "@" + DigestB
	ImageDigestRefC = ImageRepo + "@" + DigestC

	OperatorNamespaceName = "bootc-operator"
)

Test fixture values. These are not helpers per se that are any use for e2e tests, but it's a convenient global spot for now. Should probably be moved to a separate envtest-specific package.

Variables

This section is empty.

Functions

func ControlPlaneLabels

func ControlPlaneLabels() map[string]string

ControlPlaneLabels returns the conventional control-plane node label map.

func FilterEventsByObject

func FilterEventsByObject(
	items []eventsv1.Event,
	kind, name string,
	uid types.UID,
) []eventsv1.Event

FilterEventsByObject returns events regarding the identified object.

func NewK8sNode

func NewK8sNode(name string, labels map[string]string, opts ...K8sNodeOption) *corev1.Node

NewK8sNode creates a corev1.Node with the given name and labels. This is strictly used by envtests since there are no nodes there.

func NewNode

func NewNode(name, desiredImage string, opts ...NodeOption) *bootcv1alpha1.BootcNode

NewNode creates a BootcNode with the given name and desired image. DesiredImageState defaults to Staged. Override fields via functional options.

func NewPool

func NewPool(name, imageRef string, opts ...PoolOption) *bootcv1alpha1.BootcNodePool

NewPool creates a BootcNodePool with the given name and image ref. A nodeSelector must be provided via WithNodeSelector or WithWorkerSelector. Override fields via functional options.

func ShortDigest

func ShortDigest(digest string) string

ShortDigest abbreviates a "sha256:<hex>" digest the same way the controller does when rendering event notes ("sha256:" plus 12 hex characters).

func WorkerLabels

func WorkerLabels() map[string]string

WorkerLabels returns the conventional worker node label map.

Types

type K8sNodeOption

type K8sNodeOption func(*corev1.Node)

K8sNodeOption configures a corev1.Node.

type NodeOption

type NodeOption func(*bootcv1alpha1.BootcNode)

NodeOption configures a BootcNode.

func WithBootedDigest

func WithBootedDigest(digest string) NodeOption

WithBootedDigest sets the booted image digest in the node's status.

func WithDesiredImageState

func WithDesiredImageState(state bootcv1alpha1.DesiredImageState) NodeOption

WithDesiredImageState overrides the default DesiredImageState on a node.

func WithNodeAnnotation

func WithNodeAnnotation(key, value string) NodeOption

WithNodeAnnotation sets a single annotation on the node.

func WithNodeCondition

func WithNodeCondition(condType string, status metav1.ConditionStatus, reason string) NodeOption

WithNodeCondition appends a condition to the node's status.

func WithNodeConditionAt

func WithNodeConditionAt(
	condType string,
	status metav1.ConditionStatus,
	reason string,
	at time.Time,
) NodeOption

WithNodeConditionAt appends a condition with an explicit LastTransitionTime. Useful for exercising time-based logic such as reboot timeouts.

func WithNodePullSecret

func WithNodePullSecret(name, namespace string) NodeOption

WithNodePullSecret sets the pull secret reference on a node.

type PoolOption

type PoolOption func(*bootcv1alpha1.BootcNodePool)

PoolOption configures a BootcNodePool.

func WithDrainTimeoutSeconds

func WithDrainTimeoutSeconds(seconds int32) PoolOption

WithDrainTimeoutSeconds sets the rollout drain timeout in seconds.

func WithLabel

func WithLabel(key, value string) PoolOption

WithLabel sets a metadata label on the pool.

func WithMaxUnavailable

func WithMaxUnavailable(v intstr.IntOrString) PoolOption

WithMaxUnavailable sets the rollout max unavailable field.

func WithNodeSelector

func WithNodeSelector(labels map[string]string) PoolOption

WithNodeSelector sets the nodeSelector on a pool.

func WithPaused

func WithPaused(paused bool) PoolOption

WithPaused sets the rollout paused field.

func WithPullSecret

func WithPullSecret(name, namespace string) PoolOption

WithPullSecret sets the pull secret reference on a pool.

func WithRebootPolicy

func WithRebootPolicy(p bootcv1alpha1.RebootPolicy) PoolOption

WithRebootPolicy sets the disruption reboot policy.

func WithRebootTimeoutSeconds

func WithRebootTimeoutSeconds(seconds int32) PoolOption

WithRebootTimeoutSeconds sets the rollout reboot timeout in seconds.

func WithWorkerSelector

func WithWorkerSelector() PoolOption

WithWorkerSelector sets the nodeSelector to the conventional worker node label.

Jump to

Keyboard shortcuts

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