@@ -6,13 +6,15 @@ package controller
66import (
77 "context"
88 "fmt"
9+ "os"
910 "path/filepath"
1011 "runtime"
1112 "testing"
1213 "time"
1314
1415 "k8s.io/utils/ptr"
1516 "sigs.k8s.io/controller-runtime/pkg/config"
17+ metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
1618
1719 "github.com/ironcore-dev/controller-utils/modutils"
1820 metalv1alpha1 "github.com/ironcore-dev/metal-operator/api/v1alpha1"
@@ -33,6 +35,7 @@ import (
3335 "sigs.k8s.io/controller-runtime/pkg/log/zap"
3436
3537 bootv1alpha1 "github.com/ironcore-dev/boot-operator/api/v1alpha1"
38+ "github.com/ironcore-dev/boot-operator/internal/registry"
3639 //+kubebuilder:scaffold:imports
3740)
3841
@@ -61,6 +64,12 @@ func TestControllers(t *testing.T) {
6164var _ = BeforeSuite (func () {
6265 logf .SetLogger (zap .New (zap .WriteTo (GinkgoWriter ), zap .UseDevMode (true )))
6366
67+ // Set ALLOWED_REGISTRIES for tests to use ghcr.io images
68+ Expect (os .Setenv ("ALLOWED_REGISTRIES" , "ghcr.io" )).To (Succeed ())
69+ DeferCleanup (func () {
70+ Expect (os .Unsetenv ("ALLOWED_REGISTRIES" )).To (Succeed ())
71+ })
72+
6473 By ("bootstrapping test environment" )
6574 testEnv = & envtest.Environment {
6675 CRDDirectoryPaths : []string {
@@ -120,6 +129,9 @@ func SetupTest() *corev1.Namespace {
120129
121130 k8sManager , err := ctrl .NewManager (cfg , ctrl.Options {
122131 Scheme : scheme .Scheme ,
132+ Metrics : metricsserver.Options {
133+ BindAddress : "0" , // Disable metrics server to avoid port 8080 conflicts with Tilt
134+ },
123135 Controller : config.Controller {
124136 // need to skip unique controller name validation
125137 // since all tests need a dedicated controller
@@ -128,17 +140,21 @@ func SetupTest() *corev1.Namespace {
128140 })
129141 Expect (err ).ToNot (HaveOccurred ())
130142
143+ registryValidator := registry .NewValidator ()
144+
131145 Expect ((& ServerBootConfigurationPXEReconciler {
132- Client : k8sManager .GetClient (),
133- Scheme : k8sManager .GetScheme (),
134- IPXEServiceURL : "http://localhost:5000" ,
135- Architecture : "arm64" ,
146+ Client : k8sManager .GetClient (),
147+ Scheme : k8sManager .GetScheme (),
148+ IPXEServiceURL : "http://localhost:5000" ,
149+ Architecture : runtime .GOARCH ,
150+ RegistryValidator : registryValidator ,
136151 }).SetupWithManager (k8sManager )).To (Succeed ())
137152
138153 Expect ((& ServerBootConfigurationHTTPReconciler {
139- Client : k8sManager .GetClient (),
140- Scheme : k8sManager .GetScheme (),
141- ImageServerURL : "http://localhost:5000/httpboot" ,
154+ Client : k8sManager .GetClient (),
155+ Scheme : k8sManager .GetScheme (),
156+ ImageServerURL : "http://localhost:5000/httpboot" ,
157+ RegistryValidator : registryValidator ,
142158 }).SetupWithManager (k8sManager )).To (Succeed ())
143159
144160 go func () {
0 commit comments