Skip to content

Commit

Permalink
Applies gofmt and linter suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
fuero committed Oct 30, 2024
1 parent 12434a9 commit c95551c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
22 changes: 11 additions & 11 deletions pkg/stanza/operator/input/journald/config_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ func NewConfigWithID(operatorID string) *Config {
type Config struct {
helper.InputConfig `mapstructure:",squash"`

Directory *string `mapstructure:"directory,omitempty"`
Files []string `mapstructure:"files,omitempty"`
StartAt string `mapstructure:"start_at,omitempty"`
Units []string `mapstructure:"units,omitempty"`
Priority string `mapstructure:"priority,omitempty"`
Matches []MatchConfig `mapstructure:"matches,omitempty"`
Identifiers []string `mapstructure:"identifiers,omitempty"`
Grep string `mapstructure:"grep,omitempty"`
Dmesg bool `mapstructure:"dmesg,omitempty"`
All bool `mapstructure:"all,omitempty"`
Namespace string `mapstructure:"namespace,omitempty"`
Directory *string `mapstructure:"directory,omitempty"`
Files []string `mapstructure:"files,omitempty"`
StartAt string `mapstructure:"start_at,omitempty"`
Units []string `mapstructure:"units,omitempty"`
Priority string `mapstructure:"priority,omitempty"`
Matches []MatchConfig `mapstructure:"matches,omitempty"`
Identifiers []string `mapstructure:"identifiers,omitempty"`
Grep string `mapstructure:"grep,omitempty"`
Dmesg bool `mapstructure:"dmesg,omitempty"`
All bool `mapstructure:"all,omitempty"`
Namespace string `mapstructure:"namespace,omitempty"`
ConvertMessageBytes bool `mapstructure:"convert_message_bytes,omitempty"`
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/stanza/operator/input/journald/config_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error
return exec.CommandContext(ctx, "journalctl", journalArgs...) // #nosec - ...
// journalctl is an executable that is required for this operator to function
},
convert_message_bytes: c.ConvertMessageBytes,
json: jsoniter.ConfigFastest,
convertMessageBytes: c.ConvertMessageBytes,
json: jsoniter.ConfigFastest,
}, nil
}

Expand Down
28 changes: 14 additions & 14 deletions pkg/stanza/operator/input/journald/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ type Input struct {

newCmd func(ctx context.Context, cursor []byte) cmd

persister operator.Persister
json jsoniter.API
convert_message_bytes bool
cancel context.CancelFunc
wg sync.WaitGroup
errChan chan error
persister operator.Persister
json jsoniter.API
convertMessageBytes bool
cancel context.CancelFunc
wg sync.WaitGroup
errChan chan error
}

type cmd interface {
Expand Down Expand Up @@ -228,18 +228,18 @@ func (operator *Input) parseJournalEntry(line []byte) (*entry.Entry, string, err
return nil, "", fmt.Errorf("parse timestamp: %w", err)
}

if operator.convert_message_bytes {
if operator.convertMessageBytes {
// Convert the message bytes to string if given as a byte array
msg_arr, ok := body["MESSAGE"].([]interface{})
if ok {
msgArr, msgArrayOk := body["MESSAGE"].([]any)
if msgArrayOk {
var bytes []byte
for _, val := range msg_arr {
float_val, ok := val.(float64)
if ok {
bytes = append(bytes, byte(int(float_val)))
for _, val := range msgArr {
floatVal, floatCheckOk := val.(float64)
if floatCheckOk {
bytes = append(bytes, byte(int(floatVal)))
}
}
body["MESSAGE"] = string(bytes[:])
body["MESSAGE"] = string(bytes)
}
}

Expand Down

0 comments on commit c95551c

Please sign in to comment.