Skip to content

Commit

Permalink
Fix import errors in journald input (elastic#31470)
Browse files Browse the repository at this point in the history
  • Loading branch information
kvch authored and kush-elastic committed May 2, 2022
1 parent 2254bb7 commit 46a0832
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions filebeat/input/journald/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

conf "github.com/elastic/elastic-agent-libs/config"
)

func TestConfigIncludeMatches(t *testing.T) {
Expand All @@ -34,11 +36,11 @@ func TestConfigIncludeMatches(t *testing.T) {
c, err := conf.NewConfigWithYAML([]byte(yml), "source")
require.NoError(t, err)

conf := defaultConfig()
require.NoError(t, c.Unpack(&conf))
config := defaultConfig()
require.NoError(t, c.Unpack(&config))

assert.EqualValues(t, "_SYSTEMD_UNIT=foo.service", conf.Matches.OR[0].Matches[0].String())
assert.EqualValues(t, "_SYSTEMD_UNIT=bar.service", conf.Matches.OR[1].Matches[0].String())
assert.EqualValues(t, "_SYSTEMD_UNIT=foo.service", config.Matches.OR[0].Matches[0].String())
assert.EqualValues(t, "_SYSTEMD_UNIT=bar.service", config.Matches.OR[1].Matches[0].String())
}

t.Run("normal", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions filebeat/input/journald/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/statestore"
"github.com/elastic/beats/v7/libbeat/statestore/storetest"
conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/go-concert/unison"
)

Expand Down
3 changes: 2 additions & 1 deletion filebeat/input/journald/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/elastic/beats/v7/libbeat/logp"
"github.com/elastic/beats/v7/libbeat/reader"
"github.com/elastic/beats/v7/libbeat/reader/parser"
conf "github.com/elastic/elastic-agent-libs/config"
)

type journald struct {
Expand Down Expand Up @@ -105,7 +106,7 @@ func configure(cfg *conf.C) ([]cursor.Source, cursor.Input, error) {
Backoff: config.Backoff,
MaxBackoff: config.MaxBackoff,
Seek: config.Seek,
CursorSeekFallback: conf.CursorSeekFallback,
CursorSeekFallback: config.CursorSeekFallback,
Matches: journalfield.IncludeMatches(config.Matches),
Units: config.Units,
Transports: config.Transports,
Expand Down

0 comments on commit 46a0832

Please sign in to comment.