@@ -52,6 +52,14 @@ type Env struct {
5252
5353 // nodes tracks node names added via AddNode for cleanup.
5454 nodes []string
55+
56+ // nodeImageDigest is the manifest digest of the bootc image seeded
57+ // into the bink registry (e.g. "sha256:abc123..."). Empty when not seeded.
58+ nodeImageDigest string
59+
60+ // nodeImageRegistry is the in-cluster registry path for the seeded node image
61+ // (e.g. "registry.cluster.local:5000/node"). Empty when not seeded.
62+ nodeImageRegistry string
5563}
5664
5765// New connects to an existing bink cluster and returns an Env ready
@@ -70,12 +78,17 @@ func New(t *testing.T) *Env {
7078 t .Fatal ("BINK_CLUSTER_NAME must be set" )
7179 }
7280
81+ nodeImageDigest := os .Getenv ("BINK_NODE_IMAGE_DIGEST" )
82+ nodeImageRegistry := os .Getenv ("BINK_LOCAL_REGISTRY_NODE_IMAGE" )
83+
7384 k8sClient := buildClient (t , kubeconfigPath )
7485
7586 env := & Env {
76- Client : k8sClient ,
77- clusterName : clusterName ,
78- testID : sanitizeTestName (t .Name ()),
87+ Client : k8sClient ,
88+ clusterName : clusterName ,
89+ testID : sanitizeTestName (t .Name ()),
90+ nodeImageDigest : nodeImageDigest ,
91+ nodeImageRegistry : nodeImageRegistry ,
7992 }
8093
8194 t .Cleanup (func () {
@@ -89,8 +102,9 @@ func New(t *testing.T) *Env {
89102type NodeOption func (* nodeConfig )
90103
91104type nodeConfig struct {
92- memory int
93- labels map [string ]string
105+ memory int
106+ labels map [string ]string
107+ targetImgRef string
94108}
95109
96110// WithMemory sets the VM memory in MB for the node.
@@ -111,6 +125,15 @@ func WithLabel(key, value string) NodeOption {
111125 }
112126}
113127
128+ // WithTargetImgRef sets the target image reference for the node,
129+ // passed as --target-imgref to bink node add. Overrides the automatic
130+ // default that AddNode applies when registry metadata is available.
131+ func WithTargetImgRef (ref string ) NodeOption {
132+ return func (c * nodeConfig ) {
133+ c .targetImgRef = ref
134+ }
135+ }
136+
114137// AddNode provisions a worker node via bink, waits for it to be Ready,
115138// and returns the node name. The node is labeled with LabelE2ETest
116139// (and any extra labels from WithLabel).
@@ -122,6 +145,13 @@ func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string {
122145 o (cfg )
123146 }
124147
148+ if cfg .targetImgRef == "" {
149+ if e .nodeImageRegistry == "" {
150+ t .Fatal ("BINK_LOCAL_REGISTRY_NODE_IMAGE must be set (or use WithTargetImgRef)" )
151+ }
152+ cfg .targetImgRef = e .nodeImageRegistry + ":latest"
153+ }
154+
125155 nodeName := e .generateNodeName (t )
126156
127157 // Provision the node with labels applied at join time.
@@ -133,9 +163,10 @@ func (e *Env) AddNode(t *testing.T, opts ...NodeOption) string {
133163 if cfg .memory > 0 {
134164 args = append (args , "--memory" , fmt .Sprintf ("%d" , cfg .memory ))
135165 }
136- if img := os .Getenv ("BINK_NODE_IMAGE " ); img != "" {
166+ if img := os .Getenv ("BINK_NODE_DISK_IMAGE " ); img != "" {
137167 args = append (args , "--node-image" , img )
138168 }
169+ args = append (args , "--target-imgref" , cfg .targetImgRef )
139170 t .Logf ("Adding node %q..." , nodeName )
140171 if err := runBink (t , args ... ); err != nil {
141172 t .Fatalf ("adding node %q: %v" , nodeName , err )
@@ -169,6 +200,15 @@ func (e *Env) TestLabels() map[string]string {
169200 return map [string ]string {LabelE2ETest : e .testID }
170201}
171202
203+ // NodeImageDigestedPullSpec returns the digest-qualified reference for the
204+ // seeded node image (e.g. "registry.cluster.local:5000/node@sha256:abc123").
205+ func (e * Env ) NodeImageDigestedPullSpec () string {
206+ if e .nodeImageRegistry == "" || e .nodeImageDigest == "" {
207+ return ""
208+ }
209+ return e .nodeImageRegistry + "@" + e .nodeImageDigest
210+ }
211+
172212// cleanup gathers diagnostic logs, then deletes test-scoped resources
173213// and bink nodes.
174214func (e * Env ) cleanup (t * testing.T ) {
0 commit comments