Skip to content

Commit

Permalink
chore: tidy
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Sucharevich <oleg.sucharevich@elastic.co>
  • Loading branch information
olegsu committed Oct 24, 2022
1 parent c8165ad commit 31e07d6
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 202 deletions.
25 changes: 25 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,41 @@
package cmd

import (
"fmt"

"github.com/elastic/cloudbeat/beater"
"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-client/v7/pkg/proto"

cmd "github.com/elastic/beats/v7/libbeat/cmd"
"github.com/elastic/beats/v7/libbeat/cmd/instance"
"github.com/elastic/beats/v7/libbeat/common/reload"

_ "github.com/elastic/beats/v7/x-pack/libbeat/include"
"github.com/elastic/beats/v7/x-pack/libbeat/management"
)

// Name of this beat
var Name = "cloudbeat"

// RootCmd to handle beats cli
var RootCmd = cmd.GenRootCmdWithSettings(beater.New, instance.Settings{Name: Name, Version: defaultBeatVersion})

func cloudbeatCfg(rawIn *proto.UnitExpectedConfig, agentInfo *client.AgentInfo) ([]*reload.ConfigWithMeta, error) {
modules, err := management.CreateInputsFromStreams(rawIn, "logs", agentInfo)
if err != nil {
return nil, fmt.Errorf("error creating input list from raw expected config: %w", err)
}

// format for the reloadable list needed bythe cm.Reload() method
configList, err := management.CreateReloadConfigFromInputs(modules)
if err != nil {
return nil, fmt.Errorf("error creating reloader config: %w", err)
}

return configList, nil
}

func init() {
management.ConfigTransform.SetTransform(cloudbeatCfg)
}
Loading

0 comments on commit 31e07d6

Please sign in to comment.