Skip to content

Commit

Permalink
Fix lint warnings
Browse files Browse the repository at this point in the history
Fix lint warnings by moving joJournalConfig to input_linux.go
  • Loading branch information
belimawr committed Oct 22, 2024
1 parent 036f178 commit 0765233
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
41 changes: 0 additions & 41 deletions filebeat/input/systemlogs/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,47 +159,6 @@ func useJournald(c *conf.C) (bool, error) {
return true, nil
}

func toJournaldConfig(cfg *conf.C) (*conf.C, error) { //nolint:unused // It's used on Linux
newCfg, err := cfg.Child("journald", -1)
if err != nil {
return nil, fmt.Errorf("cannot extract 'journald' block: %w", err)
}

if _, err := cfg.Remove("journald", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("type", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("files", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("use_journald", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("use_files", -1); err != nil {
return nil, err
}

if err := newCfg.Merge(cfg); err != nil {
return nil, err
}

if err := newCfg.SetString("type", -1, "journald"); err != nil {
return nil, fmt.Errorf("cannot set 'type': %w", err)
}

if err := cfg.SetString("type", -1, pluginName); err != nil {
return nil, fmt.Errorf("cannot set type back to '%s': %w", pluginName, err)
}

return newCfg, nil
}

func toFilesConfig(cfg *conf.C) (*conf.C, error) {
newCfg, err := cfg.Child("files", -1)
if err != nil {
Expand Down
41 changes: 41 additions & 0 deletions filebeat/input/systemlogs/input_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,44 @@ func configure(cfg *conf.C) ([]cursor.Source, cursor.Input, error) {

return journald.Configure(journaldCfg)
}

func toJournaldConfig(cfg *conf.C) (*conf.C, error) {
newCfg, err := cfg.Child("journald", -1)
if err != nil {
return nil, fmt.Errorf("cannot extract 'journald' block: %w", err)
}

if _, err := cfg.Remove("journald", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("type", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("files", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("use_journald", -1); err != nil {
return nil, err
}

if _, err := cfg.Remove("use_files", -1); err != nil {
return nil, err
}

if err := newCfg.Merge(cfg); err != nil {
return nil, err
}

if err := newCfg.SetString("type", -1, "journald"); err != nil {
return nil, fmt.Errorf("cannot set 'type': %w", err)
}

if err := cfg.SetString("type", -1, pluginName); err != nil {
return nil, fmt.Errorf("cannot set type back to '%s': %w", pluginName, err)
}

return newCfg, nil
}

0 comments on commit 0765233

Please sign in to comment.