Skip to content

Commit fceaf8c

Browse files
committed
fix: resolve node inventory render image
1 parent 2a1992d commit fceaf8c

9 files changed

Lines changed: 114 additions & 32 deletions

controllers/nodes/deployment_handler.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"go.mondoo.com/mondoo-operator/api/v1alpha2"
1313
"go.mondoo.com/mondoo-operator/pkg/client/mondooclient"
14+
"go.mondoo.com/mondoo-operator/pkg/constants"
1415
"go.mondoo.com/mondoo-operator/pkg/utils/k8s"
1516
"go.mondoo.com/mondoo-operator/pkg/utils/mondoo"
1617
appsv1 "k8s.io/api/apps/v1"
@@ -75,6 +76,11 @@ func (n *DeploymentHandler) syncCronJob(ctx context.Context) error {
7576
logger.Error(err, "Failed to resolve mondoo-client container image")
7677
return err
7778
}
79+
renderImage, err := n.ContainerImageResolver.ContainerImage(ctx, constants.BusyBoxImage, n.MondooOperatorConfig.Spec.SkipContainerResolution)
80+
if err != nil {
81+
logger.Error(err, "Failed to resolve node inventory render container image")
82+
return err
83+
}
7884

7985
clusterUid, err := k8s.GetClusterUID(ctx, n.KubeClient, logger)
8086
if err != nil {
@@ -109,7 +115,7 @@ func (n *DeploymentHandler) syncCronJob(ctx context.Context) error {
109115
return err
110116
}
111117

112-
desired := CronJob(mondooClientImage, node, n.Mondoo, n.IsOpenshift, *n.MondooOperatorConfig)
118+
desired := CronJob(mondooClientImage, renderImage, node, n.Mondoo, n.IsOpenshift, *n.MondooOperatorConfig)
113119
cronJob := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: desired.Name, Namespace: desired.Namespace}}
114120
op, err := k8s.CreateOrUpdate(ctx, n.KubeClient, cronJob, n.Mondoo, logger, func() error {
115121
k8s.UpdateCronJobFields(cronJob, desired)
@@ -180,6 +186,11 @@ func (n *DeploymentHandler) syncDaemonSet(ctx context.Context) error {
180186
logger.Error(err, "Failed to resolve mondoo-client container image")
181187
return err
182188
}
189+
renderImage, err := n.ContainerImageResolver.ContainerImage(ctx, constants.BusyBoxImage, n.MondooOperatorConfig.Spec.SkipContainerResolution)
190+
if err != nil {
191+
logger.Error(err, "Failed to resolve node inventory render container image")
192+
return err
193+
}
183194

184195
clusterUid, err := k8s.GetClusterUID(ctx, n.KubeClient, logger)
185196
if err != nil {
@@ -229,7 +240,7 @@ func (n *DeploymentHandler) syncDaemonSet(ctx context.Context) error {
229240
}
230241
}
231242

232-
desired := DaemonSet(*n.Mondoo, n.IsOpenshift, mondooClientImage, *n.MondooOperatorConfig, slices.Collect(maps.Keys(tolerations)))
243+
desired := DaemonSet(*n.Mondoo, n.IsOpenshift, mondooClientImage, renderImage, *n.MondooOperatorConfig, slices.Collect(maps.Keys(tolerations)))
233244
ds := &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{Name: desired.Name, Namespace: desired.Namespace}}
234245
op, err := k8s.CreateOrUpdate(ctx, n.KubeClient, ds, n.Mondoo, logger, func() error {
235246
k8s.UpdateDaemonSetFields(ds, desired)

controllers/nodes/deployment_handler_test.go

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateCronJobs() {
243243
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, n.Name), Namespace: s.auditConfig.Namespace}}
244244
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
245245

246-
cjExpected := CronJob(image, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
246+
cjExpected := CronJob(image, constants.BusyBoxImage, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
247247
// Make sure the env vars for both are sorted
248248
utils.SortEnvVars(cjExpected.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
249249
utils.SortEnvVars(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
@@ -255,6 +255,40 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateCronJobs() {
255255
s.Error(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(gcCj), gcCj))
256256
}
257257

258+
func (s *DeploymentHandlerSuite) TestReconcile_CronJobUsesResolvedRenderImage() {
259+
s.seedNodes()
260+
d := s.createDeploymentHandler()
261+
d.MondooOperatorConfig = &v1alpha2.MondooOperatorConfig{Spec: v1alpha2.MondooOperatorConfigSpec{
262+
SkipContainerResolution: true,
263+
}}
264+
d.ContainerImageResolver = &fakeMondoo.ContainerImageResolverMock{
265+
CnspecImageFunc: func(userImage, userTag, userDigest string, skipResolveImage bool) (string, error) {
266+
return "registry.example.com/cnspec:13-rootless", nil
267+
},
268+
ContainerImageFunc: func(ctx context.Context, image string, skipResolveImage bool) (string, error) {
269+
s.Equal(constants.BusyBoxImage, image)
270+
s.True(skipResolveImage)
271+
return "registry.example.com/dockerhub/library/busybox:1.36", nil
272+
},
273+
}
274+
275+
mondooAuditConfig := &s.auditConfig
276+
s.NoError(d.KubeClient.Create(s.ctx, mondooAuditConfig))
277+
278+
result, err := d.Reconcile(s.ctx)
279+
s.NoError(err)
280+
s.True(result.IsZero())
281+
282+
nodes := &corev1.NodeList{}
283+
s.NoError(d.KubeClient.List(s.ctx, nodes))
284+
for _, n := range nodes.Items {
285+
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, n.Name), Namespace: s.auditConfig.Namespace}}
286+
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
287+
s.Len(cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers, 1)
288+
s.Equal("registry.example.com/dockerhub/library/busybox:1.36", cj.Spec.JobTemplate.Spec.Template.Spec.InitContainers[0].Image)
289+
}
290+
}
291+
258292
func (s *DeploymentHandlerSuite) TestReconcile_CreateCronJobs_CustomEnvVars() {
259293
s.seedNodes()
260294
d := s.createDeploymentHandler()
@@ -277,7 +311,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateCronJobs_CustomEnvVars() {
277311
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, n.Name), Namespace: s.auditConfig.Namespace}}
278312
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
279313

280-
cjExpected := CronJob(image, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
314+
cjExpected := CronJob(image, constants.BusyBoxImage, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
281315
// Make sure the env vars for both are sorted
282316
utils.SortEnvVars(cjExpected.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
283317
utils.SortEnvVars(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
@@ -310,7 +344,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateCronJobs_Switch() {
310344
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, n.Name), Namespace: s.auditConfig.Namespace}}
311345
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
312346

313-
cjExpected := CronJob(image, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
347+
cjExpected := CronJob(image, constants.BusyBoxImage, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
314348
// Make sure the env vars for both are sorted
315349
utils.SortEnvVars(cjExpected.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
316350
utils.SortEnvVars(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
@@ -350,7 +384,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_UpdateCronJobs() {
350384
s.NoError(err)
351385

352386
// Make sure a cron job exists for one of the nodes
353-
cj := CronJob(image, nodes.Items[1], &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
387+
cj := CronJob(image, constants.BusyBoxImage, nodes.Items[1], &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
354388
cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command = []string{"test-command"}
355389
s.NoError(d.KubeClient.Create(s.ctx, cj))
356390

@@ -362,7 +396,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_UpdateCronJobs() {
362396
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, n.Name), Namespace: s.auditConfig.Namespace}}
363397
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
364398

365-
cjExpected := CronJob(image, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
399+
cjExpected := CronJob(image, constants.BusyBoxImage, n, &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
366400
// Make sure the env vars for both are sorted
367401
utils.SortEnvVars(cjExpected.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
368402
utils.SortEnvVars(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
@@ -408,7 +442,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CleanCronJobsForDeletedNodes() {
408442
cj := &batchv1.CronJob{ObjectMeta: metav1.ObjectMeta{Name: CronJobName(s.auditConfig.Name, nodes.Items[0].Name), Namespace: s.auditConfig.Namespace}}
409443
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(cj), cj))
410444

411-
cjExpected := CronJob(image, nodes.Items[0], &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
445+
cjExpected := CronJob(image, constants.BusyBoxImage, nodes.Items[0], &s.auditConfig, false, v1alpha2.MondooOperatorConfig{})
412446
// Make sure the env vars for both are sorted
413447
utils.SortEnvVars(cjExpected.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
414448
utils.SortEnvVars(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env)
@@ -436,7 +470,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateDaemonSets() {
436470
ds := &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{Name: DaemonSetName(s.auditConfig.Name), Namespace: s.auditConfig.Namespace}}
437471
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(ds), ds))
438472

439-
dsExpected := DaemonSet(s.auditConfig, false, image, v1alpha2.MondooOperatorConfig{},
473+
dsExpected := DaemonSet(s.auditConfig, false, image, constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{},
440474
[]corev1.Toleration{{Key: "node-role.kubernetes.io/master", Value: "true", Effect: corev1.TaintEffectNoExecute}})
441475
// Make sure the env vars for both are sorted
442476
utils.SortEnvVars(dsExpected.Spec.Template.Spec.Containers[0].Env)
@@ -469,7 +503,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_CreateDaemonSets_Switch() {
469503
ds := &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{Name: DaemonSetName(s.auditConfig.Name), Namespace: s.auditConfig.Namespace}}
470504
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(ds), ds))
471505

472-
dsExpected := DaemonSet(s.auditConfig, false, image, v1alpha2.MondooOperatorConfig{},
506+
dsExpected := DaemonSet(s.auditConfig, false, image, constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{},
473507
[]corev1.Toleration{{Key: "node-role.kubernetes.io/master", Value: "true", Effect: corev1.TaintEffectNoExecute}})
474508
s.Equal(dsExpected.Spec, ds.Spec)
475509

@@ -507,7 +541,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_UpdateDaemonSets() {
507541
s.NoError(err)
508542

509543
// Make sure a daemonset exists
510-
ds := DaemonSet(s.auditConfig, false, image, v1alpha2.MondooOperatorConfig{}, nil)
544+
ds := DaemonSet(s.auditConfig, false, image, constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{}, nil)
511545
ds.Spec.Template.Spec.Containers[0].Command = []string{"test-command"}
512546
s.NoError(d.KubeClient.Create(s.ctx, ds))
513547

@@ -518,7 +552,7 @@ func (s *DeploymentHandlerSuite) TestReconcile_UpdateDaemonSets() {
518552
ds = &appsv1.DaemonSet{ObjectMeta: metav1.ObjectMeta{Name: DaemonSetName(s.auditConfig.Name), Namespace: s.auditConfig.Namespace}}
519553
s.NoError(d.KubeClient.Get(s.ctx, client.ObjectKeyFromObject(ds), ds))
520554

521-
depExpected := DaemonSet(s.auditConfig, false, image, v1alpha2.MondooOperatorConfig{},
555+
depExpected := DaemonSet(s.auditConfig, false, image, constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{},
522556
[]corev1.Toleration{{Key: "node-role.kubernetes.io/master", Value: "true", Effect: corev1.TaintEffectNoExecute}})
523557
s.Equal(depExpected.Spec, ds.Spec)
524558
}

controllers/nodes/resources.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const (
4444
)
4545

4646
// CronJob creates a CronJob for node scanning
47-
func CronJob(image string, node corev1.Node, m *v1alpha2.MondooAuditConfig, isOpenshift bool, cfg v1alpha2.MondooOperatorConfig) *batchv1.CronJob {
47+
func CronJob(image, renderImage string, node corev1.Node, m *v1alpha2.MondooAuditConfig, isOpenshift bool, cfg v1alpha2.MondooOperatorConfig) *batchv1.CronJob {
4848
ls := NodeScanningLabels(*m)
4949
cmd := []string{
5050
"cnspec", "scan", "local",
@@ -106,7 +106,7 @@ func CronJob(image string, node corev1.Node, m *v1alpha2.MondooAuditConfig, isOp
106106
// should not be mounted at all.
107107
AutomountServiceAccountToken: ptr.To(false),
108108
InitContainers: []corev1.Container{
109-
renderNodeInventoryInitContainer(node.Name),
109+
renderNodeInventoryInitContainer(node.Name, renderImage),
110110
},
111111
Containers: []corev1.Container{
112112
{
@@ -195,7 +195,7 @@ func CronJob(image string, node corev1.Node, m *v1alpha2.MondooAuditConfig, isOp
195195
}
196196

197197
// DaemonSet creates a DaemonSet for node scanning
198-
func DaemonSet(m v1alpha2.MondooAuditConfig, isOpenshift bool, image string, cfg v1alpha2.MondooOperatorConfig, tolerations []corev1.Toleration) *appsv1.DaemonSet {
198+
func DaemonSet(m v1alpha2.MondooAuditConfig, isOpenshift bool, image, renderImage string, cfg v1alpha2.MondooOperatorConfig, tolerations []corev1.Toleration) *appsv1.DaemonSet {
199199
labels := NodeScanningLabels(m)
200200
cmd := []string{
201201
"cnspec", "serve",
@@ -243,7 +243,7 @@ func DaemonSet(m v1alpha2.MondooAuditConfig, isOpenshift bool, image string, cfg
243243
AutomountServiceAccountToken: ptr.To(false),
244244
Tolerations: tolerations,
245245
InitContainers: []corev1.Container{
246-
renderNodeInventoryInitContainer(""),
246+
renderNodeInventoryInitContainer("", renderImage),
247247
},
248248
Containers: []corev1.Container{
249249
{
@@ -431,7 +431,7 @@ func Inventory(integrationMRN, clusterUID string, m v1alpha2.MondooAuditConfig)
431431
return string(invBytes), nil
432432
}
433433

434-
func renderNodeInventoryInitContainer(nodeName string) corev1.Container {
434+
func renderNodeInventoryInitContainer(nodeName, image string) corev1.Container {
435435
render := fmt.Sprintf("sed \"s#%s#${NODE_NAME}#g\" %s > %s",
436436
nodeInventoryNodeNamePlaceholder,
437437
shellQuote(nodeInventoryTemplatePath),
@@ -450,7 +450,7 @@ func renderNodeInventoryInitContainer(nodeName string) corev1.Container {
450450

451451
return corev1.Container{
452452
Name: "render-node-inventory",
453-
Image: constants.BusyBoxImage,
453+
Image: image,
454454
ImagePullPolicy: corev1.PullIfNotPresent,
455455
Command: []string{"/bin/sh", "-ec", render},
456456
Env: env,

controllers/nodes/resources_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestResources(t *testing.T) {
120120
},
121121
}
122122
mac := test.mondooauditconfig()
123-
cj := CronJob("test123", testNode, mac, false, v1alpha2.MondooOperatorConfig{})
123+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, v1alpha2.MondooOperatorConfig{})
124124
assert.Equal(t, test.expectedResources, cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Resources)
125125
})
126126
}
@@ -175,7 +175,7 @@ func TestResources_GOMEMLIMIT(t *testing.T) {
175175
},
176176
}
177177
mac := test.mondooauditconfig()
178-
cj := CronJob("test123", testNode, mac, false, v1alpha2.MondooOperatorConfig{})
178+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, v1alpha2.MondooOperatorConfig{})
179179
goMemLimitEnv := corev1.EnvVar{}
180180
for _, env := range cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Env {
181181
if env.Name == "GOMEMLIMIT" {
@@ -190,7 +190,7 @@ func TestResources_GOMEMLIMIT(t *testing.T) {
190190
for _, test := range tests {
191191
t.Run(test.name, func(t *testing.T) {
192192
mac := *test.mondooauditconfig()
193-
ds := DaemonSet(mac, false, "test123", v1alpha2.MondooOperatorConfig{}, nil)
193+
ds := DaemonSet(mac, false, "test123", constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{}, nil)
194194
goMemLimitEnv := corev1.EnvVar{}
195195
for _, env := range ds.Spec.Template.Spec.Containers[0].Env {
196196
if env.Name == "GOMEMLIMIT" {
@@ -210,7 +210,7 @@ func TestCronJob_PrivilegedOpenshift(t *testing.T) {
210210
},
211211
}
212212
mac := testMondooAuditConfig()
213-
cj := CronJob("test123", testNode, mac, true, v1alpha2.MondooOperatorConfig{})
213+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, true, v1alpha2.MondooOperatorConfig{})
214214
assert.True(t, *cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].SecurityContext.Privileged)
215215
assert.True(t, *cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].SecurityContext.AllowPrivilegeEscalation)
216216
}
@@ -222,7 +222,7 @@ func TestCronJob_Privileged(t *testing.T) {
222222
},
223223
}
224224
mac := testMondooAuditConfig()
225-
cj := CronJob("test123", testNode, mac, false, v1alpha2.MondooOperatorConfig{})
225+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, v1alpha2.MondooOperatorConfig{})
226226
assert.False(t, *cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].SecurityContext.Privileged)
227227
assert.False(t, *cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].SecurityContext.AllowPrivilegeEscalation)
228228
}
@@ -278,7 +278,7 @@ func TestCronJob_WithProxy(t *testing.T) {
278278
},
279279
}
280280

281-
cj := CronJob("test123", testNode, mac, false, cfg)
281+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, cfg)
282282
container := cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0]
283283

284284
cmdStr := strings.Join(container.Command, " ")
@@ -294,7 +294,7 @@ func TestCronJob_UsesInventoryFileFlag(t *testing.T) {
294294
testNode := corev1.Node{ObjectMeta: metav1.ObjectMeta{Name: "test-node-name"}}
295295
mac := testMondooAuditConfig()
296296

297-
cj := CronJob("test123", testNode, mac, false, v1alpha2.MondooOperatorConfig{})
297+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, v1alpha2.MondooOperatorConfig{})
298298
mainCommand := strings.Join(cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0].Command, " ")
299299

300300
assert.Contains(t, mainCommand, "cnspec scan local")
@@ -329,7 +329,7 @@ func TestCronJob_SkipProxyForCnspec(t *testing.T) {
329329
},
330330
}
331331

332-
cj := CronJob("test123", testNode, mac, false, cfg)
332+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, cfg)
333333
container := cj.Spec.JobTemplate.Spec.Template.Spec.Containers[0]
334334

335335
cmdStr := strings.Join(container.Command, " ")
@@ -351,7 +351,7 @@ func TestCronJob_WithImagePullSecrets(t *testing.T) {
351351
},
352352
}
353353

354-
cj := CronJob("test123", testNode, mac, false, cfg)
354+
cj := CronJob("test123", constants.BusyBoxImage, testNode, mac, false, cfg)
355355
secrets := cj.Spec.JobTemplate.Spec.Template.Spec.ImagePullSecrets
356356
require.Len(t, secrets, 1)
357357
assert.Equal(t, "my-registry-secret", secrets[0].Name)
@@ -366,7 +366,7 @@ func TestDaemonSet_WithProxy(t *testing.T) {
366366
},
367367
}
368368

369-
ds := DaemonSet(mac, false, "test123", cfg, nil)
369+
ds := DaemonSet(mac, false, "test123", constants.BusyBoxImage, cfg, nil)
370370
container := ds.Spec.Template.Spec.Containers[0]
371371

372372
cmdStr := strings.Join(container.Command, " ")
@@ -381,7 +381,7 @@ func TestDaemonSet_WithProxy(t *testing.T) {
381381
func TestDaemonSet_UsesInventoryFileFlag(t *testing.T) {
382382
mac := *testMondooAuditConfig()
383383

384-
ds := DaemonSet(mac, false, "test123", v1alpha2.MondooOperatorConfig{}, nil)
384+
ds := DaemonSet(mac, false, "test123", constants.BusyBoxImage, v1alpha2.MondooOperatorConfig{}, nil)
385385
mainCommand := strings.Join(ds.Spec.Template.Spec.Containers[0].Command, " ")
386386

387387
assert.Contains(t, mainCommand, "cnspec serve")
@@ -417,7 +417,7 @@ func TestDaemonSet_SkipProxyForCnspec(t *testing.T) {
417417
},
418418
}
419419

420-
ds := DaemonSet(mac, false, "test123", cfg, nil)
420+
ds := DaemonSet(mac, false, "test123", constants.BusyBoxImage, cfg, nil)
421421
container := ds.Spec.Template.Spec.Containers[0]
422422

423423
cmdStr := strings.Join(container.Command, " ")
@@ -438,7 +438,7 @@ func TestDaemonSet_WithImagePullSecrets(t *testing.T) {
438438
},
439439
}
440440

441-
ds := DaemonSet(mac, false, "test123", cfg, nil)
441+
ds := DaemonSet(mac, false, "test123", constants.BusyBoxImage, cfg, nil)
442442
secrets := ds.Spec.Template.Spec.ImagePullSecrets
443443
require.Len(t, secrets, 1)
444444
assert.Equal(t, "my-registry-secret", secrets[0].Name)

controllers/status/operator_status_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,10 @@ func (m *mockContainerImageResolver) MondooOperatorImage(_ context.Context, _, _
218218
return "ghcr.io/mondoohq/mondoo-operator@sha256:def456", nil
219219
}
220220

221+
func (m *mockContainerImageResolver) ContainerImage(_ context.Context, image string, _ bool) (string, error) {
222+
return image, nil
223+
}
224+
221225
func (m *mockContainerImageResolver) WithImageRegistry(_ string) mondooutils.ContainerImageResolver {
222226
return m
223227
}

docs/user-manual.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ spec:
11811181
enable: true
11821182
```
11831183

1184-
Node scanning pods include a lightweight `render-node-inventory` init container that renders the node-specific inventory file before `cnspec` starts. This keeps custom scanner images simple: the scanner image must provide `cnspec`, but it does not need a POSIX shell or `sed`.
1184+
Node scanning pods include a lightweight `render-node-inventory` init container that renders the node-specific inventory file before `cnspec` starts. This keeps custom scanner images simple: the scanner image must provide `cnspec`, but it does not need a POSIX shell or `sed`. The init container image uses the same `imageRegistry`, `registryMirrors`, `imagePullSecrets`, and `skipContainerResolution` settings as other operator-managed images.
11851185

11861186
### Why are (some of) my nodes unscored?
11871187

0 commit comments

Comments
 (0)