forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Elastic Agent] Support an application spec to be ran through service…
… manager (eg. Endpoint) (elastic#19205) (elastic#19487) * Initial spec parsing for endpoint. * Update comment. * Fix spec test. * Update code so it copies the entire input. * Fix ast test. * Merge agent-improve-restart-loop * Merge agent-endpoint-spec * Refactor core/plugin/app into mostly core/ and use core/plugin for different app types. * Work on endpoint service application. * More fixes. * Fix format and tests. * Fix some imports. * More cleanups. * Fix export comment. * Pass the program.Spec into the descriptor. * Fix some small issues with service app. * Fix lint and tests. * Remove the code no longer needed because of newer config format. * Fix rules and review. (cherry picked from commit ac51570)
- Loading branch information
1 parent
7a9e29d
commit d831809
Showing
60 changed files
with
674 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
x-pack/elastic-agent/pkg/agent/application/fleet_decorator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package application | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" | ||
"github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" | ||
) | ||
|
||
func injectFleet(cfg *config.Config) func(*logger.Logger, *transpiler.AST) error { | ||
return func(logger *logger.Logger, rootAst *transpiler.AST) error { | ||
config, err := cfg.ToMapStr() | ||
if err != nil { | ||
return err | ||
} | ||
ast, err := transpiler.NewAST(config) | ||
if err != nil { | ||
return err | ||
} | ||
api, ok := transpiler.Lookup(ast, "api") | ||
if !ok { | ||
return fmt.Errorf("failed to get api from fleet config") | ||
} | ||
agentInfo, ok := transpiler.Lookup(ast, "agent_info") | ||
if !ok { | ||
return fmt.Errorf("failed to get agent_info from fleet config") | ||
} | ||
fleet := transpiler.NewDict([]transpiler.Node{agentInfo, api}) | ||
err = transpiler.Insert(rootAst, fleet, "fleet") | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.