@@ -65,19 +65,19 @@ func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) {
65
65
66
66
log .Info ("Config initiated." )
67
67
68
- fetchersRegistry , err := InitRegistry (c )
68
+ fetchersRegistry , err := InitRegistry (log , c )
69
69
if err != nil {
70
70
cancel ()
71
71
return nil , err
72
72
}
73
73
74
- data , err := manager .NewData (c .Period , time .Minute , fetchersRegistry )
74
+ data , err := manager .NewData (log , c .Period , time .Minute , fetchersRegistry )
75
75
if err != nil {
76
76
cancel ()
77
77
return nil , err
78
78
}
79
79
80
- eval , err := evaluator .NewOpaEvaluator (ctx )
80
+ eval , err := evaluator .NewOpaEvaluator (ctx , log )
81
81
if err != nil {
82
82
cancel ()
83
83
return nil , err
@@ -90,7 +90,7 @@ func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) {
90
90
return nil , err
91
91
}
92
92
93
- cdp , err := transformer .NewCommonDataProvider (c )
93
+ cdp , err := transformer .NewCommonDataProvider (log , c )
94
94
if err != nil {
95
95
cancel ()
96
96
return nil , err
@@ -102,13 +102,13 @@ func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) {
102
102
return nil , err
103
103
}
104
104
105
- t := transformer .NewTransformer (ctx , eval , commonData , resultsIndex )
105
+ t := transformer .NewTransformer (ctx , log , eval , commonData , resultsIndex )
106
106
107
107
bt := & cloudbeat {
108
108
ctx : ctx ,
109
109
cancel : cancel ,
110
110
config : c ,
111
- configUpdates : config .Updates (ctx ),
111
+ configUpdates : config .Updates (ctx , log ),
112
112
evaluator : eval ,
113
113
data : data ,
114
114
transformer : t ,
@@ -155,33 +155,33 @@ func (bt *cloudbeat) Run(b *beat.Beat) error {
155
155
156
156
case update := <- bt .configUpdates :
157
157
if err := bt .config .Update (update ); err != nil {
158
- logp . L () .Errorf ("Could not update cloudbeat config: %v" , err )
158
+ bt . log .Errorf ("Could not update cloudbeat config: %v" , err )
159
159
break
160
160
}
161
161
162
162
policies , err := csppolicies .CISKubernetes ()
163
163
if err != nil {
164
- logp . L () .Errorf ("Could not load CIS Kubernetes policies: %v" , err )
164
+ bt . log .Errorf ("Could not load CIS Kubernetes policies: %v" , err )
165
165
break
166
166
}
167
167
168
168
if len (bt .config .Streams ) == 0 {
169
- logp . L () .Infof ("Did not receive any input stream, skipping." )
169
+ bt . log .Infof ("Did not receive any input stream, skipping." )
170
170
break
171
171
}
172
172
173
173
y , err := bt .config .DataYaml ()
174
174
if err != nil {
175
- logp . L () .Errorf ("Could not marshal to YAML: %v" , err )
175
+ bt . log .Errorf ("Could not marshal to YAML: %v" , err )
176
176
break
177
177
}
178
178
179
179
if err := csppolicies .HostBundleWithDataYaml ("bundle.tar.gz" , policies , y ); err != nil {
180
- logp . L () .Errorf ("Could not update bundle with dataYaml: %v" , err )
180
+ bt . log .Errorf ("Could not update bundle with dataYaml: %v" , err )
181
181
break
182
182
}
183
183
184
- logp . L () .Infof ("Bundle updated with dataYaml: %s" , y )
184
+ bt . log .Infof ("Bundle updated with dataYaml: %s" , y )
185
185
186
186
case fetchedResources := <- output :
187
187
cycleId , _ := uuid .NewV4 ()
@@ -195,12 +195,13 @@ func (bt *cloudbeat) Run(b *beat.Beat) error {
195
195
}
196
196
}
197
197
198
- func InitRegistry (c config.Config ) (manager.FetchersRegistry , error ) {
199
- registry := manager .NewFetcherRegistry ()
200
- err := manager . Factories . RegisterFetchers ( registry , c )
201
- if err != nil {
198
+ func InitRegistry (log * logp. Logger , c config.Config ) (manager.FetchersRegistry , error ) {
199
+ registry := manager .NewFetcherRegistry (log )
200
+
201
+ if err := manager . Factories . RegisterFetchers ( log , registry , c ); err != nil {
202
202
return nil , err
203
203
}
204
+
204
205
return registry , nil
205
206
}
206
207
0 commit comments