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
- func ControlPlaneLabels() map[string]string
- func FilterEventsByObject(items []eventsv1.Event, kind, name string, uid types.UID) []eventsv1.Event
- func NewK8sNode(name string, labels map[string]string, opts ...K8sNodeOption) *corev1.Node
- func NewNode(name, desiredImage string, opts ...NodeOption) *bootcv1alpha1.BootcNode
- func NewPool(name, imageRef string, opts ...PoolOption) *bootcv1alpha1.BootcNodePool
- func ShortDigest(digest string) string
- func WorkerLabels() map[string]string
- type K8sNodeOption
- type NodeOption
- func WithBootedDigest(digest string) NodeOption
- func WithDesiredImageState(state bootcv1alpha1.DesiredImageState) NodeOption
- func WithNodeAnnotation(key, value string) NodeOption
- func WithNodeCondition(condType string, status metav1.ConditionStatus, reason string) NodeOption
- func WithNodeConditionAt(condType string, status metav1.ConditionStatus, reason string, at time.Time) NodeOption
- func WithNodePullSecret(name, namespace string) NodeOption
- type PoolOption
- func WithDrainTimeoutSeconds(seconds int32) PoolOption
- func WithLabel(key, value string) PoolOption
- func WithMaxUnavailable(v intstr.IntOrString) PoolOption
- func WithNodeSelector(labels map[string]string) PoolOption
- func WithPaused(paused bool) PoolOption
- func WithPullSecret(name, namespace string) PoolOption
- func WithRebootPolicy(p bootcv1alpha1.RebootPolicy) PoolOption
- func WithRebootTimeoutSeconds(seconds int32) PoolOption
- func WithWorkerSelector() PoolOption
Constants ¶
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 ¶
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 ¶
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 ¶
ShortDigest abbreviates a "sha256:<hex>" digest the same way the controller does when rendering event notes ("sha256:" plus 12 hex characters).
func WorkerLabels ¶
WorkerLabels returns the conventional worker node label map.
Types ¶
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 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.