@@ -14,8 +14,12 @@ import (
1414 detector "github.com/rancher/kubernetes-provider-detector"
1515 "github.com/rancher/wrangler/pkg/apply"
1616 "github.com/rancher/wrangler/pkg/crd"
17+ appsctl "github.com/rancher/wrangler/pkg/generated/controllers/apps"
18+ appsctlv1 "github.com/rancher/wrangler/pkg/generated/controllers/apps/v1"
1719 batchctl "github.com/rancher/wrangler/pkg/generated/controllers/batch"
20+ batchctlv1 "github.com/rancher/wrangler/pkg/generated/controllers/batch/v1"
1821 corectl "github.com/rancher/wrangler/pkg/generated/controllers/core"
22+ corectlv1 "github.com/rancher/wrangler/pkg/generated/controllers/core/v1"
1923 "github.com/rancher/wrangler/pkg/start"
2024
2125 "sync"
@@ -24,6 +28,7 @@ import (
2428
2529 cisoperatorapiv1 "github.com/rancher/cis-operator/pkg/apis/cis.cattle.io/v1"
2630 cisoperatorctl "github.com/rancher/cis-operator/pkg/generated/controllers/cis.cattle.io"
31+ cisoperatorctlv1 "github.com/rancher/cis-operator/pkg/generated/controllers/cis.cattle.io/v1"
2732 "github.com/rancher/cis-operator/pkg/securityscan/scan"
2833)
2934
@@ -38,11 +43,13 @@ type Controller struct {
3843 xcs * kubeapiext.Clientset
3944 coreFactory * corectl.Factory
4045 batchFactory * batchctl.Factory
46+ appsFactory * appsctl.Factory
4147 cisFactory * cisoperatorctl.Factory
4248 apply apply.Apply
4349 monitoringClient v1monitoringclient.MonitoringV1Interface
4450
45- mu * sync.Mutex
51+ mu * sync.Mutex
52+ currentScanName string
4653
4754 numTestsFailed * prometheus.GaugeVec
4855 numScansComplete * prometheus.CounterVec
@@ -51,6 +58,16 @@ type Controller struct {
5158 numTestsNA * prometheus.GaugeVec
5259 numTestsPassed * prometheus.GaugeVec
5360 numTestsWarn * prometheus.GaugeVec
61+
62+ scans cisoperatorctlv1.ClusterScanController
63+ jobs batchctlv1.JobController
64+ configmaps corectlv1.ConfigMapController
65+ configMapCache corectlv1.ConfigMapCache
66+ services corectlv1.ServiceController
67+ pods corectlv1.PodController
68+ podCache corectlv1.PodCache
69+ daemonsets appsctlv1.DaemonSetController
70+ daemonsetCache appsctlv1.DaemonSetCache
5471}
5572
5673func NewController (ctx context.Context , cfg * rest.Config , namespace , name string , imgConfig * cisoperatorapiv1.ScanImageConfig ) (ctl * Controller , err error ) {
@@ -112,6 +129,11 @@ func NewController(ctx context.Context, cfg *rest.Config, namespace, name string
112129 return nil , fmt .Errorf ("Error building core NewFactoryFromConfig: %s" , err .Error ())
113130 }
114131
132+ ctl .appsFactory , err = appsctl .NewFactoryFromConfig (cfg )
133+ if err != nil {
134+ return nil , fmt .Errorf ("Error building apps NewFactoryFromConfig: %s" , err .Error ())
135+ }
136+
115137 ctl .monitoringClient , err = v1monitoringclient .NewForConfig (cfg )
116138 if err != nil {
117139 return nil , fmt .Errorf ("Error building v1 monitoring client from config: %s" , err .Error ())
@@ -121,6 +143,17 @@ func NewController(ctx context.Context, cfg *rest.Config, namespace, name string
121143 if err != nil {
122144 return nil , fmt .Errorf ("Error registering CIS Metrics: %s" , err .Error ())
123145 }
146+
147+ ctl .scans = ctl .cisFactory .Cis ().V1 ().ClusterScan ()
148+ ctl .jobs = ctl .batchFactory .Batch ().V1 ().Job ()
149+ ctl .configmaps = ctl .coreFactory .Core ().V1 ().ConfigMap ()
150+ ctl .configMapCache = ctl .coreFactory .Core ().V1 ().ConfigMap ().Cache ()
151+ ctl .services = ctl .coreFactory .Core ().V1 ().Service ()
152+ ctl .pods = ctl .coreFactory .Core ().V1 ().Pod ()
153+ ctl .podCache = ctl .coreFactory .Core ().V1 ().Pod ().Cache ()
154+ ctl .daemonsets = ctl .appsFactory .Apps ().V1 ().DaemonSet ()
155+ ctl .daemonsetCache = ctl .appsFactory .Apps ().V1 ().DaemonSet ().Cache ()
156+
124157 return ctl , nil
125158}
126159
0 commit comments