Skip to content

Commit

Permalink
Support endpoint on every platform but centos/redhat 7 on arm (#27256) (
Browse files Browse the repository at this point in the history
#28449)

(cherry picked from commit a1c6774)

Co-authored-by: Michal Pristas <[email protected]>
  • Loading branch information
mergify[bot] and michalpristas authored Oct 15, 2021
1 parent 982bd48 commit 24de193
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
26 changes: 21 additions & 5 deletions x-pack/elastic-agent/pkg/agent/application/info/inject_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ import (
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/paths"
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors"
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config"
"github.com/elastic/go-sysinfo"
)

// InjectAgentConfig injects config to a provided configuration.
func InjectAgentConfig(c *config.Config) error {
globalConfig := agentGlobalConfig()
globalConfig, err := agentGlobalConfig()
if err != nil {
return err
}

if err := c.Merge(globalConfig); err != nil {
return errors.New("failed to inject agent global config", err, errors.TypeConfig)
}
Expand All @@ -24,15 +29,26 @@ func InjectAgentConfig(c *config.Config) error {

// agentGlobalConfig gets global config used for resolution of variables inside configuration
// such as ${path.data}.
func agentGlobalConfig() map[string]interface{} {
func agentGlobalConfig() (map[string]interface{}, error) {
hostInfo, err := sysinfo.Host()
if err != nil {
return nil, err
}

return map[string]interface{}{
"path": map[string]interface{}{
"data": paths.Data(),
"config": paths.Config(),
"home": paths.Home(),
"logs": paths.Logs(),
},
"runtime.os": runtime.GOOS,
"runtime.arch": runtime.GOARCH,
}
"runtime.os": runtime.GOOS,
"runtime.arch": runtime.GOARCH,
"runtime.osinfo.type": hostInfo.Info().OS.Type,
"runtime.osinfo.family": hostInfo.Info().OS.Family,
"runtime.osinfo.version": hostInfo.Info().OS.Version,
"runtime.osinfo.major": hostInfo.Info().OS.Major,
"runtime.osinfo.minor": hostInfo.Info().OS.Minor,
"runtime.osinfo.patch": hostInfo.Info().OS.Patch,
}, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func (e *Controller) Update(c *config.Config) error {
if err != nil {
return errors.New(err, "could not create the AST from the configuration", errors.TypeConfig)
}

rawAst, err := transpiler.NewAST(m)
if err != nil {
return errors.New(err, "could not create the AST from the configuration", errors.TypeConfig)
Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/agent/program/supported.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x-pack/elastic-agent/spec/endpoint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ rules:
- revision

when: length(${fleet}) > 0 and length(${inputs}) > 0 and hasKey(${output}, 'elasticsearch')
constraints: ${runtime.arch} != 'arm64'
constraints: ${runtime.arch} != 'arm64' and ${runtime.family} != 'redhat' and ${runtime.major} != '7'

0 comments on commit 24de193

Please sign in to comment.