Skip to content

Commit 35e1d9d

Browse files
authored
refact: remove unused struct fields (#3633)
1 parent f6f7cc3 commit 35e1d9d

File tree

5 files changed

+11
-21
lines changed

5 files changed

+11
-21
lines changed

pkg/acquisition/acquisition_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,9 @@ func TestLoadAcquisitionFromFiles(t *testing.T) {
316316

317317
type MockCat struct {
318318
configuration.DataSourceCommonCfg `yaml:",inline"`
319-
logger *log.Entry
320319
}
321320

322-
func (f *MockCat) Configure(_ []byte, logger *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
323-
f.logger = logger
321+
func (f *MockCat) Configure(_ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
324322
if f.Mode == "" {
325323
f.Mode = configuration.CAT_MODE
326324
}
@@ -353,11 +351,9 @@ func (*MockCat) GetUuid() string { return "" }
353351

354352
type MockTail struct {
355353
configuration.DataSourceCommonCfg `yaml:",inline"`
356-
logger *log.Entry
357354
}
358355

359-
func (f *MockTail) Configure(_ []byte, logger *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
360-
f.logger = logger
356+
func (f *MockTail) Configure(_ []byte, _ *log.Entry, _ metrics.AcquisitionMetricsLevel) error {
361357
if f.Mode == "" {
362358
f.Mode = configuration.TAIL_MODE
363359
}
@@ -574,9 +570,12 @@ func (*TailModeNoTailer) CanRun() error { return nil }
574570
func TestStartAcquisition_MissingTailer(t *testing.T) {
575571
ctx := t.Context()
576572
out := make(chan types.Event)
577-
var tb tomb.Tomb
578573
errCh := make(chan error, 1)
574+
575+
var tb tomb.Tomb
576+
579577
go func() { errCh <- StartAcquisition(ctx, []DataSource{&TailModeNoTailer{}}, out, &tb) }()
578+
580579
require.ErrorContains(t, <-errCh, "tail_no_tailer: tail mode is set but StreamingAcquisition is not supported")
581580
}
582581

@@ -594,8 +593,11 @@ func (*CatModeNoFetcher) CanRun() error { return nil }
594593
func TestStartAcquisition_MissingFetcher(t *testing.T) {
595594
ctx := t.Context()
596595
out := make(chan types.Event)
597-
var tb tomb.Tomb
598596
errCh := make(chan error, 1)
597+
598+
var tb tomb.Tomb
599+
599600
go func() { errCh <- StartAcquisition(ctx, []DataSource{&CatModeNoFetcher{}}, out, &tb) }()
601+
600602
require.ErrorContains(t, <-errCh, "cat_no_fetcher: cat mode is set but OneShotAcquisition is not supported")
601603
}

pkg/acquisition/modules/appsec/appsec.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,10 @@ type AppsecSourceConfig struct {
6262

6363
// runtime structure of AppsecSourceConfig
6464
type AppsecSource struct {
65-
metricsLevel metrics.AcquisitionMetricsLevel
6665
config AppsecSourceConfig
6766
logger *log.Entry
6867
mux *http.ServeMux
6968
server *http.Server
70-
outChan chan types.Event
7169
InChan chan appsec.ParsedRequest
7270
AppsecRuntime *appsec.AppsecRuntimeConfig
7371
AppsecConfigs map[string]appsec.AppsecConfig
@@ -209,7 +207,6 @@ func (w *AppsecSource) Configure(yamlConfig []byte, logger *log.Entry, metricsLe
209207
}
210208

211209
w.logger = logger
212-
w.metricsLevel = metricsLevel
213210
w.logger.Tracef("Appsec configuration: %+v", w.config)
214211

215212
if w.config.AuthCacheDuration == nil {
@@ -433,8 +430,6 @@ func (w *AppsecSource) listenAndServe(ctx context.Context, t *tomb.Tomb) error {
433430
}
434431

435432
func (w *AppsecSource) StreamingAcquisition(ctx context.Context, out chan types.Event, t *tomb.Tomb) error {
436-
w.outChan = out
437-
438433
apiClient, err := apiclient.GetLAPIClient()
439434
if err != nil {
440435
return fmt.Errorf("unable to get authenticated LAPI client: %w", err)

pkg/apiclient/auth_key.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"net/http"
66
"net/http/httputil"
7-
"net/url"
87

98
log "github.com/sirupsen/logrus"
109
)
@@ -14,8 +13,6 @@ type APIKeyTransport struct {
1413
// Transport is the underlying HTTP transport to use when making requests.
1514
// It will default to http.DefaultTransport if nil.
1615
Transport http.RoundTripper
17-
URL *url.URL
18-
VersionPrefix string
1916
UserAgent string
2017
}
2118

pkg/apiserver/apic.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ type apic struct {
6666
pullTomb tomb.Tomb
6767
metricsTomb tomb.Tomb
6868
startup bool
69-
credentials *csconfig.ApiCredentialsCfg
7069
consoleConfig *csconfig.ConsoleConfig
7170
isPulling chan bool
7271
whitelists *csconfig.CapiWhitelist
@@ -195,7 +194,6 @@ func NewAPIC(ctx context.Context, config *csconfig.OnlineApiClientCfg, dbClient
195194
dbClient: dbClient,
196195
mu: sync.Mutex{},
197196
startup: true,
198-
credentials: config.Credentials,
199197
pullTomb: tomb.Tomb{},
200198
pushTomb: tomb.Tomb{},
201199
metricsTomb: tomb.Tomb{},

pkg/apiserver/apiserver.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type APIServer struct {
3838
UnixSocket string
3939
TLS *csconfig.TLSCfg
4040
dbClient *database.Client
41-
logFile string
4241
controller *controllers.Controller
4342
flushScheduler *gocron.Scheduler
4443
router *gin.Engine
@@ -204,7 +203,7 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
204203
}
205204

206205
// The logger that will be used by handlers
207-
clog, logFile, err := newGinLogger(config)
206+
clog, _, err := newGinLogger(config)
208207
if err != nil {
209208
return nil, err
210209
}
@@ -286,7 +285,6 @@ func NewServer(ctx context.Context, config *csconfig.LocalApiServerCfg) (*APISer
286285
URL: config.ListenURI,
287286
UnixSocket: config.ListenSocket,
288287
TLS: config.TLS,
289-
logFile: logFile,
290288
dbClient: dbClient,
291289
controller: controller,
292290
flushScheduler: flushScheduler,

0 commit comments

Comments
 (0)