Skip to content

Commit 1106131

Browse files
authored
Merge pull request #265 from kubescape/reg-state
reg state
2 parents cd01cd3 + 4ec4516 commit 1106131

File tree

8 files changed

+109
-69
lines changed

8 files changed

+109
-69
lines changed

admission/exporter/http_exporter.go

+46-22
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,53 @@ func (exporter *HTTPExporter) sendInAlertList(httpAlert apitypes.RuntimeAlert, p
156156
logger.L().Error("failed to marshal HTTPAlertsList", helpers.Error(err))
157157
return
158158
}
159-
bodyReader := bytes.NewReader(bodyBytes)
160159

161-
// send the HTTP request
162-
req, err := http.NewRequest(exporter.config.Method,
163-
exporter.config.URL+"/v1/runtimealerts", bodyReader)
160+
exporter.exportMessage("runtimealerts", bodyBytes)
161+
}
162+
163+
func (exporter *HTTPExporter) checkAlertLimit() bool {
164+
exporter.alertCountLock.Lock()
165+
defer exporter.alertCountLock.Unlock()
166+
167+
if exporter.alertCountStart.IsZero() {
168+
exporter.alertCountStart = time.Now()
169+
}
170+
171+
if time.Since(exporter.alertCountStart) > time.Minute {
172+
exporter.alertCountStart = time.Now()
173+
exporter.alertCount = 0
174+
exporter.alertLimitNotified = false
175+
}
176+
177+
exporter.alertCount++
178+
return exporter.alertCount > exporter.config.MaxAlertsPerMinute
179+
}
180+
181+
func (exporter *HTTPExporter) SendRegistryStatus(guid string, status apitypes.RegistryScanStatus, statusMessage string, time time.Time) {
182+
updateRegistryStatusCRD := apitypes.GenericCRD[apitypes.ContainerImageRegistryScanStatusUpdate]{
183+
Kind: apitypes.RegistryScanStatusKind,
184+
ApiVersion: "kubescape.io/v1",
185+
Metadata: apitypes.Metadata{},
186+
Spec: apitypes.ContainerImageRegistryScanStatusUpdate{
187+
GUID: guid,
188+
ScanStatus: status,
189+
ScanStatusMessage: statusMessage,
190+
ScanTime: time,
191+
},
192+
}
193+
194+
bodyBytes, err := json.Marshal(updateRegistryStatusCRD)
195+
if err != nil {
196+
logger.L().Error("failed to marshal updateRegistryStatusCRD", helpers.Error(err))
197+
return
198+
}
199+
200+
exporter.exportMessage(apitypes.RegistryScanStatusPath, bodyBytes)
201+
}
202+
203+
func (exporter *HTTPExporter) exportMessage(path string, bodyBytes []byte) {
204+
bodyReader := bytes.NewReader(bodyBytes)
205+
req, err := http.NewRequest(exporter.config.Method, fmt.Sprintf("%s/v1/%s", exporter.config.URL, path), bodyReader)
164206
if err != nil {
165207
logger.L().Error("failed to create HTTP request", helpers.Error(err))
166208
return
@@ -186,21 +228,3 @@ func (exporter *HTTPExporter) sendInAlertList(httpAlert apitypes.RuntimeAlert, p
186228
logger.L().Error("failed to clear response body", helpers.Error(err))
187229
}
188230
}
189-
190-
func (exporter *HTTPExporter) checkAlertLimit() bool {
191-
exporter.alertCountLock.Lock()
192-
defer exporter.alertCountLock.Unlock()
193-
194-
if exporter.alertCountStart.IsZero() {
195-
exporter.alertCountStart = time.Now()
196-
}
197-
198-
if time.Since(exporter.alertCountStart) > time.Minute {
199-
exporter.alertCountStart = time.Now()
200-
exporter.alertCount = 0
201-
exporter.alertLimitNotified = false
202-
}
203-
204-
exporter.alertCount++
205-
return exporter.alertCount > exporter.config.MaxAlertsPerMinute
206-
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.23.0
55
toolchain go1.23.2
66

77
require (
8-
github.com/armosec/armoapi-go v0.0.475
8+
github.com/armosec/armoapi-go v0.0.481
99
github.com/armosec/cluster-notifier-api-go v0.0.5
1010
github.com/armosec/registryx v0.0.22
1111
github.com/armosec/utils-go v0.0.58

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmV
139139
github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc=
140140
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
141141
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
142-
github.com/armosec/armoapi-go v0.0.475 h1:VM8OcG+etjyHru4fvK8CSqgLWhlzry8ae46LRjSzdys=
143-
github.com/armosec/armoapi-go v0.0.475/go.mod h1:TruqDSAPgfRBXCeM+Cgp6nN4UhJSbe7la+XDKV2pTsY=
142+
github.com/armosec/armoapi-go v0.0.481 h1:kr/6mmi5Ux69gGwzihX0IWpm0whkNcXVsbo3st7zHDk=
143+
github.com/armosec/armoapi-go v0.0.481/go.mod h1:TruqDSAPgfRBXCeM+Cgp6nN4UhJSbe7la+XDKV2pTsY=
144144
github.com/armosec/cluster-notifier-api-go v0.0.5 h1:UKY58ehKocKgtqzrawyaIHJa5paG9A4srv+4/6n+Ez4=
145145
github.com/armosec/cluster-notifier-api-go v0.0.5/go.mod h1:p5w9/zWIWwpi8W8mHGQdE6HuBb3AxXmZM9Rp//JWvx0=
146146
github.com/armosec/gojay v1.2.17 h1:VSkLBQzD1c2V+FMtlGFKqWXNsdNvIKygTKJI9ysY8eM=

main.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,13 @@ func main() {
115115
go servicehandler.DiscoveryServiceHandler(ctx, k8sApi, components.ServiceScanConfig.Interval)
116116
}
117117

118+
exporter, err := exporters.InitHTTPExporter(*operatorConfig.HttpExporterConfig(), operatorConfig.ClusterName())
119+
if err != nil {
120+
logger.L().Ctx(ctx).Fatal("failed to initialize HTTP exporter", helpers.Error(err))
121+
}
122+
118123
// setup main handler
119-
mainHandler := mainhandler.NewMainHandler(operatorConfig, k8sApi)
124+
mainHandler := mainhandler.NewMainHandler(operatorConfig, k8sApi, exporter)
120125

121126
if components.Components.Gateway.Enabled {
122127
go func() { // open websocket connection to notification server
@@ -162,11 +167,6 @@ func main() {
162167

163168
addr := ":8443"
164169

165-
exporter, err := exporters.InitHTTPExporter(*operatorConfig.HttpExporterConfig(), operatorConfig.ClusterName())
166-
if err != nil {
167-
logger.L().Ctx(ctx).Fatal("failed to initialize HTTP exporter", helpers.Error(err))
168-
}
169-
170170
// Create watchers
171171
dWatcher := dynamicwatcher.NewWatchHandler(k8sApi, operatorConfig.SkipNamespace)
172172

mainhandler/handlerequests.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package mainhandler
33
import (
44
"context"
55
"fmt"
6+
exporters "github.com/kubescape/operator/admission/exporter"
67
"os"
78
"regexp"
89
"time"
@@ -48,6 +49,7 @@ type MainHandler struct {
4849
commandResponseChannel *commandResponseChannelData
4950
config config.IConfig
5051
sendReport bool
52+
exporter *exporters.HTTPExporter
5153
}
5254

5355
type ActionHandler struct {
@@ -58,6 +60,7 @@ type ActionHandler struct {
5860
commandResponseChannel *commandResponseChannelData
5961
wlid string
6062
sendReport bool
63+
exporter *exporters.HTTPExporter
6164
}
6265

6366
type waitFunc func(clusterConfig config.IConfig)
@@ -79,7 +82,7 @@ func init() {
7982
}
8083

8184
// CreateWebSocketHandler Create ws-handler obj
82-
func NewMainHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi) *MainHandler {
85+
func NewMainHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi, exporter *exporters.HTTPExporter) *MainHandler {
8386

8487
commandResponseChannel := make(chan *CommandResponseData, 100)
8588
limitedGoRoutinesCommandResponseChannel := make(chan *timerData, 10)
@@ -88,6 +91,7 @@ func NewMainHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi) *
8891
commandResponseChannel: &commandResponseChannelData{commandResponseChannel: &commandResponseChannel, limitedGoRoutinesCommandResponseChannel: &limitedGoRoutinesCommandResponseChannel},
8992
config: config,
9093
sendReport: config.EventReceiverURL() != "",
94+
exporter: exporter,
9195
}
9296
pool, _ := ants.NewPoolWithFunc(config.ConcurrencyWorkers(), func(i interface{}) {
9397
j, ok := i.(utils.Job)
@@ -102,14 +106,15 @@ func NewMainHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi) *
102106
}
103107

104108
// CreateWebSocketHandler Create ws-handler obj
105-
func NewActionHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi, sessionObj *utils.SessionObj, commandResponseChannel *commandResponseChannelData) *ActionHandler {
109+
func NewActionHandler(config config.IConfig, k8sAPI *k8sinterface.KubernetesApi, sessionObj *utils.SessionObj, commandResponseChannel *commandResponseChannelData, exporter *exporters.HTTPExporter) *ActionHandler {
106110
return &ActionHandler{
107111
reporter: sessionObj.Reporter,
108112
command: sessionObj.Command,
109113
k8sAPI: k8sAPI,
110114
commandResponseChannel: commandResponseChannel,
111115
config: config,
112116
sendReport: config.EventReceiverURL() != "",
117+
exporter: exporter,
113118
}
114119
}
115120

@@ -217,7 +222,7 @@ func (mainHandler *MainHandler) HandleSingleRequest(ctx context.Context, session
217222
ctx, span := otel.Tracer("").Start(ctx, "mainHandler.HandleSingleRequest")
218223
defer span.End()
219224

220-
actionHandler := NewActionHandler(mainHandler.config, mainHandler.k8sAPI, sessionObj, mainHandler.commandResponseChannel)
225+
actionHandler := NewActionHandler(mainHandler.config, mainHandler.k8sAPI, sessionObj, mainHandler.commandResponseChannel, mainHandler.exporter)
221226
actionHandler.reporter.SetActionName(string(sessionObj.Command.CommandName))
222227
actionHandler.reporter.SendDetails("Handling single request", mainHandler.sendReport)
223228

@@ -261,7 +266,7 @@ func (actionHandler *ActionHandler) runCommand(ctx context.Context, sessionObj *
261266
case apis.TypeDeleteRegistryScanCronJob:
262267
return actionHandler.deleteRegistryScanCronJob(ctx)
263268
case apis.TypeScanRegistryV2:
264-
return actionHandler.scanRegistriesV2(ctx, sessionObj)
269+
return actionHandler.scanRegistriesV2AndUpdateStatus(ctx, sessionObj)
265270
default:
266271
logger.L().Ctx(ctx).Error(fmt.Sprintf("Command %s not found", c.CommandName))
267272
}

mainhandler/imageregistryhandler.go

-5
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,6 @@ func (registryScan *registryScan) setRegistryInfoFromAuth(auth registryAuth, reg
763763

764764
func (registryScan *registryScan) getRegistryConfig(registryInfo *armotypes.RegistryInfo) (string, error) {
765765
configMap, err := registryScan.k8sAPI.GetWorkload(registryScan.config.Namespace(), "ConfigMap", registryScanConfigmap)
766-
// in case of an error or missing configmap, fallback to the deprecated namespace
767-
if err != nil || configMap == nil {
768-
configMap, err = registryScan.k8sAPI.GetWorkload(armotypes.ArmoSystemNamespace, "ConfigMap", registryScanConfigmap)
769-
}
770-
771766
if err != nil {
772767
// if configmap not found, it means we will use all images and default depth
773768
if strings.Contains(err.Error(), fmt.Sprintf("reason: configmaps \"%v\" not found", registryScanConfigmap)) {

mainhandler/vulnscan.go

+33-16
Original file line numberDiff line numberDiff line change
@@ -159,41 +159,55 @@ func (actionHandler *ActionHandler) scanRegistries(ctx context.Context, sessionO
159159
return actionHandler.scanRegistry(ctx, registryScan, sessionObj)
160160
}
161161

162-
func (actionHandler *ActionHandler) scanRegistriesV2(ctx context.Context, sessionObj *utils.SessionObj) error {
163-
ctx, span := otel.Tracer("").Start(ctx, "actionHandler.scanRegistries")
162+
func (actionHandler *ActionHandler) scanRegistriesV2AndUpdateStatus(ctx context.Context, sessionObj *utils.SessionObj) error {
163+
ctx, span := otel.Tracer("").Start(ctx, "actionHandler.scanRegistriesV2")
164164
defer span.End()
165165

166166
if !actionHandler.config.Components().Kubevuln.Enabled {
167167
return errors.New("kubevuln is not enabled")
168168
}
169169

170-
// send change status of registry to scanning
170+
scanTime := time.Now()
171171
imageRegistry, err := actionHandler.loadRegistryFromSessionObj(sessionObj)
172172
if err != nil {
173-
return fmt.Errorf("scanRegistriesV2 failed to load registry from sessionObj with err %v", err)
173+
return fmt.Errorf("failed to load registry from sessionObj with err %v", err)
174174
}
175175

176-
if err = actionHandler.loadRegistrySecret(ctx, sessionObj, imageRegistry); err != nil {
177-
return fmt.Errorf("scanRegistriesV2 failed to load secret with err %v", err)
176+
err = actionHandler.scanRegistriesV2(ctx, sessionObj, imageRegistry)
177+
if err != nil {
178+
actionHandler.exporter.SendRegistryStatus(imageRegistry.GetBase().GUID, apitypes.Failed, err.Error(), scanTime)
179+
return err
180+
}
181+
182+
actionHandler.exporter.SendRegistryStatus(imageRegistry.GetBase().GUID, apitypes.InProgress, "", scanTime)
183+
return nil
184+
}
185+
186+
func (actionHandler *ActionHandler) scanRegistriesV2(ctx context.Context, sessionObj *utils.SessionObj, imageRegistry apitypes.ContainerImageRegistry) error {
187+
if err := actionHandler.loadRegistrySecret(ctx, sessionObj, imageRegistry); err != nil {
188+
return fmt.Errorf("failed to load secret with err %v", err)
178189
}
179190

180191
client, err := registryclients.GetRegistryClient(imageRegistry)
181192
if err != nil {
182-
return fmt.Errorf("scanRegistriesV2 failed to get registry client with err %v", err)
193+
return fmt.Errorf("failed to get registry client with err %v", err)
183194
}
184195

185196
images, err := client.GetImagesToScan(ctx)
186197
if err != nil {
187-
return fmt.Errorf("scanRegistriesV2 failed to get registry images to scan with err %v", err)
198+
return fmt.Errorf("failed to get registry images to scan with err %v", err)
188199
}
189200

190201
registryScanCMDList, err := actionHandler.getRegistryImageScanCommands(sessionObj, client, imageRegistry, images)
191202
if err != nil {
192-
return fmt.Errorf("scanRegistriesV2 failed to get registry images scan commands with err %v", err)
203+
return fmt.Errorf("failed to get registry images scan commands with err %v", err)
193204
}
194205
sessionObj.Reporter.SendDetails(fmt.Sprintf("sending %d images from registry %v to vuln scan", len(registryScanCMDList), imageRegistry), actionHandler.sendReport)
206+
if err = sendAllImagesToRegistryScan(ctx, actionHandler.config, registryScanCMDList); err != nil {
207+
return fmt.Errorf("failed to send scan commands with err %v", err)
208+
}
195209

196-
return sendAllImagesToRegistryScan(ctx, actionHandler.config, registryScanCMDList)
210+
return nil
197211
}
198212

199213
func (actionHandler *ActionHandler) loadRegistrySecret(ctx context.Context, sessionObj *utils.SessionObj, imageRegistry apitypes.ContainerImageRegistry) error {
@@ -229,6 +243,7 @@ func (actionHandler *ActionHandler) loadRegistryFromSessionObj(sessionObj *utils
229243
}
230244

231245
func (actionHandler *ActionHandler) getRegistryImageScanCommands(sessionObj *utils.SessionObj, client interfaces.RegistryClient, imageRegistry apitypes.ContainerImageRegistry, images map[string]string) ([]*apis.RegistryScanCommand, error) {
246+
scanID := uuid.NewString()
232247
registryScanCMDList := make([]*apis.RegistryScanCommand, 0, len(images))
233248
for image, tag := range images {
234249
repository := image
@@ -242,12 +257,14 @@ func (actionHandler *ActionHandler) getRegistryImageScanCommands(sessionObj *uti
242257
ImageTag: image + ":" + tag,
243258
Session: apis.SessionChain{ActionTitle: "vulnerability-scan", JobIDs: make([]string, 0), Timestamp: sessionObj.Reporter.GetTimestamp()},
244259
Args: map[string]interface{}{
245-
identifiers.AttributeRegistryName: imageRegistry.GetDisplayName(),
246-
identifiers.AttributeRepository: repository,
247-
identifiers.AttributeTag: tag,
248-
identifiers.AttributeUseHTTP: false,
249-
identifiers.AttributeSkipTLSVerify: false,
250-
identifiers.AttributeSensor: imageRegistry.GetBase().ClusterName,
260+
identifiers.AttributeRegistryName: imageRegistry.GetDisplayName(),
261+
identifiers.AttributeRepository: repository,
262+
identifiers.AttributeTag: tag,
263+
identifiers.AttributeUseHTTP: false,
264+
identifiers.AttributeSkipTLSVerify: false,
265+
identifiers.AttributeSensor: imageRegistry.GetBase().ClusterName,
266+
identifiers.AttributeRegistryID: imageRegistry.GetBase().GUID,
267+
identifiers.AttributeRegistryScanID: scanID,
251268
},
252269
}
253270
auth, err := client.GetDockerAuth()

watcher/commandswatcher_test.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
_ "embed"
66
"encoding/json"
7-
"github.com/armosec/armoapi-go/armotypes"
87
utilsmetadata "github.com/armosec/utils-k8s-go/armometadata"
98
"github.com/kubescape/backend/pkg/command"
109
"github.com/kubescape/backend/pkg/command/types/v1alpha1"
@@ -46,44 +45,44 @@ func TestRegistryCommandWatch(t *testing.T) {
4645
var cmd unstructured.Unstructured
4746
err := json.Unmarshal(createRegistryCommand, &cmd)
4847
require.NoError(t, err)
49-
_, err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace(armotypes.KubescapeNamespace).Create(ctx, &cmd, v1.CreateOptions{})
48+
_, err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace("kubescape").Create(ctx, &cmd, v1.CreateOptions{})
5049
require.NoError(t, err)
5150

5251
// let registry command handler consume the command
5352
time.Sleep(time.Second * 10)
5453

5554
// verify resources are created
5655
resourceName := "kubescape-registry-scan-2122797310"
57-
configMap, err := k8sAPI.KubernetesClient.CoreV1().ConfigMaps(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
56+
configMap, err := k8sAPI.KubernetesClient.CoreV1().ConfigMaps("kubescape").Get(ctx, resourceName, v1.GetOptions{})
5857
require.NoError(t, err)
5958
require.NotNil(t, configMap)
60-
secret, err := k8sAPI.KubernetesClient.CoreV1().Secrets(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
59+
secret, err := k8sAPI.KubernetesClient.CoreV1().Secrets("kubescape").Get(ctx, resourceName, v1.GetOptions{})
6160
require.NoError(t, err)
6261
require.NotNil(t, secret)
63-
cronjob, err := k8sAPI.KubernetesClient.BatchV1().CronJobs(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
62+
cronjob, err := k8sAPI.KubernetesClient.BatchV1().CronJobs("kubescape").Get(ctx, resourceName, v1.GetOptions{})
6463
require.NoError(t, err)
6564
require.NotNil(t, cronjob)
6665

6766
// delete existing command - usually done by the BE
68-
err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace(armotypes.KubescapeNamespace).Delete(ctx, "52601522-359f-4417-a140-cf60e57302f6", v1.DeleteOptions{})
67+
err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace("kubescape").Delete(ctx, "52601522-359f-4417-a140-cf60e57302f6", v1.DeleteOptions{})
6968
require.NoError(t, err)
7069

7170
// send delete command
7271
deleteCommandStr := strings.ReplaceAll(string(createRegistryCommand), string(command.OperatorCommandTypeCreateRegistry), string(command.OperatorCommandTypeDeleteRegistry))
7372
err = json.Unmarshal([]byte(deleteCommandStr), &cmd)
7473
require.NoError(t, err)
75-
_, err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace(armotypes.KubescapeNamespace).Create(ctx, &cmd, v1.CreateOptions{})
74+
_, err = k8sAPI.DynamicClient.Resource(v1alpha1.SchemaGroupVersionResource).Namespace("kubescape").Create(ctx, &cmd, v1.CreateOptions{})
7675
require.NoError(t, err)
7776

7877
// let registry command handler consume the command
7978
time.Sleep(time.Second * 10)
8079

8180
// verify resources are deleted
82-
_, err = k8sAPI.KubernetesClient.CoreV1().ConfigMaps(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
81+
_, err = k8sAPI.KubernetesClient.CoreV1().ConfigMaps("kubescape").Get(ctx, resourceName, v1.GetOptions{})
8382
require.ErrorContains(t, err, "not found")
84-
_, err = k8sAPI.KubernetesClient.CoreV1().Secrets(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
83+
_, err = k8sAPI.KubernetesClient.CoreV1().Secrets("kubescape").Get(ctx, resourceName, v1.GetOptions{})
8584
require.ErrorContains(t, err, "not found")
86-
_, err = k8sAPI.KubernetesClient.BatchV1().CronJobs(armotypes.KubescapeNamespace).Get(ctx, resourceName, v1.GetOptions{})
85+
_, err = k8sAPI.KubernetesClient.BatchV1().CronJobs("kubescape").Get(ctx, resourceName, v1.GetOptions{})
8786
require.ErrorContains(t, err, "not found")
8887

8988
}
@@ -108,7 +107,7 @@ func setupEnvAndWatchers(t *testing.T, ctx context.Context, k8sAPI *k8sinterface
108107
// add kubescape namespace
109108
namespace := &corev1.Namespace{
110109
ObjectMeta: v1.ObjectMeta{
111-
Name: armotypes.KubescapeNamespace,
110+
Name: "kubescape",
112111
},
113112
}
114113
_, err = k8sAPI.KubernetesClient.CoreV1().Namespaces().Create(ctx, namespace, v1.CreateOptions{})
@@ -117,11 +116,11 @@ func setupEnvAndWatchers(t *testing.T, ctx context.Context, k8sAPI *k8sinterface
117116
// add registry cronjob template
118117
var cjTemplate corev1.ConfigMap
119118
require.NoError(t, yaml.Unmarshal(registryTemplateConfiMap, &cjTemplate))
120-
_, err = k8sAPI.KubernetesClient.CoreV1().ConfigMaps(armotypes.KubescapeNamespace).Create(ctx, &cjTemplate, v1.CreateOptions{})
119+
_, err = k8sAPI.KubernetesClient.CoreV1().ConfigMaps("kubescape").Create(ctx, &cjTemplate, v1.CreateOptions{})
121120
require.NoError(t, err)
122121

123122
// start watcher
124-
operatorConfig := config.NewOperatorConfig(config.CapabilitiesConfig{}, utilsmetadata.ClusterConfig{}, &beUtils.Credentials{}, "", config.Config{Namespace: armotypes.KubescapeNamespace})
123+
operatorConfig := config.NewOperatorConfig(config.CapabilitiesConfig{}, utilsmetadata.ClusterConfig{}, &beUtils.Credentials{}, "", config.Config{Namespace: "kubescape"})
125124
commandWatchHandler := NewCommandWatchHandler(k8sAPI, operatorConfig)
126125
registryCommandsHandler := NewRegistryCommandsHandler(ctx, k8sAPI, commandWatchHandler, operatorConfig)
127126
go registryCommandsHandler.Start()

0 commit comments

Comments
 (0)