Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{,x-pack/}filebeat: clean up dead code #30483

Merged
merged 2 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions filebeat/beater/acker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ func TestACKer(t *testing.T) {
{
name: "only stateful",
data: []interface{}{file.State{Source: "-"}, file.State{Source: "-"}},
stateful: []file.State{file.State{Source: "-"}, file.State{Source: "-"}},
stateful: []file.State{{Source: "-"}, {Source: "-"}},
stateless: 0,
},
{
name: "both",
data: []interface{}{file.State{Source: "-"}, nil, file.State{Source: "-"}},
stateful: []file.State{file.State{Source: "-"}, file.State{Source: "-"}},
stateful: []file.State{{Source: "-"}, {Source: "-"}},
stateless: 1,
},
{
Expand Down
4 changes: 1 addition & 3 deletions filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ const pipelinesWarning = "Filebeat is unable to load the ingest pipelines for th
" already loaded the ingest pipelines or are using Logstash pipelines, you" +
" can ignore this warning."

var (
once = flag.Bool("once", false, "Run filebeat only once until all harvesters reach EOF")
)
var once = flag.Bool("once", false, "Run filebeat only once until all harvesters reach EOF")

// Filebeat is a beater object. Contains all objects needed to run the beat
type Filebeat struct {
Expand Down
5 changes: 0 additions & 5 deletions filebeat/beater/signalwait.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package beater

import (
"sync"
"time"

"github.com/elastic/beats/v7/libbeat/logp"
Expand Down Expand Up @@ -71,10 +70,6 @@ func (s *signalWait) Signal() {
s.Add(func() {})
}

func waitGroup(wg *sync.WaitGroup) signaler {
return wg.Wait
}

func waitChannel(c <-chan struct{}) signaler {
return func() { <-c }
}
Expand Down
3 changes: 1 addition & 2 deletions filebeat/channel/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ func newCommonConfigEditor(
var indexProcessor processors.Processor
if !config.Index.IsEmpty() {
staticFields := fmtstr.FieldsForBeat(beatInfo.Beat, beatInfo.Version)
timestampFormat, err :=
fmtstr.NewTimestampFormatString(&config.Index, staticFields)
timestampFormat, err := fmtstr.NewTimestampFormatString(&config.Index, staticFields)
if err != nil {
return nil, err
}
Expand Down
1 change: 0 additions & 1 deletion filebeat/channel/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ func (o *subOutlet) Done() <-chan struct{} {
}

func (o *subOutlet) OnEvent(event beat.Event) bool {

o.mutex.Lock()
defer o.mutex.Unlock()
select {
Expand Down
4 changes: 1 addition & 3 deletions filebeat/cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (
"github.com/elastic/beats/v7/libbeat/paths"
)

var (
defaultHomePath = paths.Resolve(paths.Home, "")
)
var defaultHomePath = paths.Resolve(paths.Home, "")

func genGenerateCmd() *cobra.Command {
generateCmd := cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion filebeat/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var RootCmd *cmd.BeatsRootCmd

// FilebeatSettings contains the default settings for filebeat
func FilebeatSettings() instance.Settings {
var runFlags = pflag.NewFlagSet(Name, pflag.ExitOnError)
runFlags := pflag.NewFlagSet(Name, pflag.ExitOnError)
runFlags.AddGoFlag(flag.CommandLine.Lookup("once"))
runFlags.AddGoFlag(flag.CommandLine.Lookup("modules"))
return instance.Settings{
Expand Down
24 changes: 10 additions & 14 deletions filebeat/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,16 @@ type Registry struct {
MigrateFile string `config:"migrate_file"`
}

var (
DefaultConfig = Config{
Registry: Registry{
Path: "registry",
Permissions: 0600,
MigrateFile: "",
CleanInterval: 5 * time.Minute,
},
ShutdownTimeout: 0,
OverwritePipelines: false,
}
)
var DefaultConfig = Config{
Registry: Registry{
Path: "registry",
Permissions: 0o600,
MigrateFile: "",
CleanInterval: 5 * time.Minute,
},
ShutdownTimeout: 0,
OverwritePipelines: false,
}

// getConfigFiles returns list of config files.
// In case path is a file, it will be directly returned.
Expand All @@ -86,7 +84,6 @@ func getConfigFiles(path string) (configFiles []string, err error) {

if stat.IsDir() {
files, err := filepath.Glob(path + "/*.yml")

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -138,7 +135,6 @@ func (config *Config) FetchConfigs() error {
logp.Info("Additional config files are fetched from: %s", configDir)

configFiles, err := getConfigFiles(configDir)

if err != nil {
log.Fatal("Could not use config_dir of: ", configDir, err)
return err
Expand Down
Loading