Skip to content

Commit 8f24875

Browse files
committed
wip2
1 parent ec968d8 commit 8f24875

File tree

3 files changed

+8
-27
lines changed

3 files changed

+8
-27
lines changed

pkg/acquisition/acquisition.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/crowdsecurity/go-cs-lib/trace"
2727

2828
"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration"
29-
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
3029
"github.com/crowdsecurity/crowdsec/pkg/csconfig"
3130
"github.com/crowdsecurity/crowdsec/pkg/cwhub"
3231
"github.com/crowdsecurity/crowdsec/pkg/cwversion/component"
@@ -118,7 +117,6 @@ type DSNConfigurer interface {
118117
}
119118

120119
type LAPIClientAware interface {
121-
SetClient(client *apiclient.ApiClient)
122120
SetClientConfig(config *csconfig.LocalApiClientCfg)
123121
}
124122

@@ -193,15 +191,7 @@ func DataSourceConfigure(ctx context.Context, commonConfig configuration.DataSou
193191
}
194192

195193
if lapiClientAware, ok := dataSrc.(LAPIClientAware); ok {
196-
apiClient, err := apiclient.GetLAPIClient()
197-
if err != nil {
198-
return nil, fmt.Errorf("unable to get authenticated LAPI client: %w", err)
199-
}
200-
201-
lapiClientAware.SetClient(apiClient)
202-
203194
cConfig := csconfig.GetConfig()
204-
205195
lapiClientAware.SetClientConfig(cConfig.API.Client)
206196
}
207197

@@ -240,15 +230,7 @@ func LoadAcquisitionFromDSN(ctx context.Context, dsn string, labels map[string]s
240230
}
241231

242232
if lapiClientAware, ok := dataSrc.(LAPIClientAware); ok {
243-
apiClient, err := apiclient.GetLAPIClient()
244-
if err != nil {
245-
return nil, fmt.Errorf("unable to get authenticated LAPI client: %w", err)
246-
}
247-
248-
lapiClientAware.SetClient(apiClient)
249-
250233
cConfig := csconfig.GetConfig()
251-
252234
lapiClientAware.SetClientConfig(cConfig.API.Client)
253235
}
254236

pkg/acquisition/modules/appsec/config.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
log "github.com/sirupsen/logrus"
1818

1919
"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration"
20+
"github.com/crowdsecurity/crowdsec/pkg/apiclient"
2021
"github.com/crowdsecurity/crowdsec/pkg/apiclient/useragent"
2122
"github.com/crowdsecurity/crowdsec/pkg/appsec"
2223
"github.com/crowdsecurity/crowdsec/pkg/appsec/allowlists"
@@ -120,16 +121,18 @@ func (w *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Ent
120121
return errors.New("appsec datasource requires a hub. this is a bug, please report")
121122
}
122123

123-
if w.lapiClient == nil {
124-
return errors.New("appsec datasource requires a lapi client. this is a bug, please report")
125-
}
126-
127124
if w.lapiClientConfig == nil {
128125
return errors.New("appsec datasource requires a lapi client configuration. this is a bug, please report")
129126
}
130127

131-
err := w.UnmarshalConfig(yamlConfig)
128+
client, err := apiclient.GetLAPIClient()
132129
if err != nil {
130+
return fmt.Errorf("unable to get authenticated LAPI client: %w", err)
131+
}
132+
133+
w.lapiClient = client
134+
135+
if err := w.UnmarshalConfig(yamlConfig); err != nil {
133136
return fmt.Errorf("unable to parse appsec configuration: %w", err)
134137
}
135138

pkg/acquisition/modules/appsec/source.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ func (ac *AuthCache) Delete(apiKey string) {
6767
ac.mu.Unlock()
6868
}
6969

70-
func (w *Source) SetClient(client *apiclient.ApiClient) {
71-
w.lapiClient = client
72-
}
73-
7470
func (w *Source) SetClientConfig(config *csconfig.LocalApiClientCfg) {
7571
w.lapiClientConfig = config
7672
}

0 commit comments

Comments
 (0)