diff --git a/.travis.yml b/.travis.yml index e4f03562ebe..f6c6f3e6ae6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -161,6 +161,18 @@ jobs: go: $TRAVIS_GO_VERSION stage: test + # Agent + - os: linux + before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0 + env: TARGETS="-C x-pack/elastic-agent testsuite" + go: $TRAVIS_GO_VERSION + stage: test + - os: osx + before_install: .ci/scripts/travis_has_changes.sh x-pack/elastic-agent libbeat || travis_terminate 0 + env: TARGETS="TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite" + go: $TRAVIS_GO_VERSION + stage: test + # Generators - os: linux env: TARGETS="-C generator/_templates/metricbeat test test-package" diff --git a/Jenkinsfile b/Jenkinsfile index 26e5a37fec5..5538fffecca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,6 +55,48 @@ pipeline { stage('Build and Test'){ failFast false parallel { + stage('Elastic Agent x-pack'){ + agent { label 'ubuntu && immutable' } + options { skipDefaultCheckout() } + when { + beforeAgent true + expression { + return env.BUILD_ELASTIC_AGENT_XPACK != "false" + } + } + steps { + makeTarget("Elastic Agent x-pack Linux", "-C x-pack/elastic-agent testsuite") + } + } + + stage('Elastic Agent x-pack Windows'){ + agent { label 'windows-immutable && windows-2019' } + options { skipDefaultCheckout() } + when { + beforeAgent true + expression { + return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.windowsTest + } + } + steps { + mageTargetWin("Elastic Agent x-pack Windows Unit test", "x-pack/elastic-agent", "unitTest") + } + } + + stage('Elastic Agent Mac OS X'){ + agent { label 'macosx' } + options { skipDefaultCheckout() } + when { + beforeAgent true + expression { + return env.BUILD_ELASTIC_AGENT_XPACK != "false" && params.macosTest + } + } + steps { + makeTarget("Elastic Agent x-pack Mac OS X", "TEST_ENVIRONMENT=0 -C x-pack/elastic-agent testsuite") + } + } + stage('Filebeat oss'){ agent { label 'ubuntu && immutable' } options { skipDefaultCheckout() } @@ -892,5 +934,9 @@ def loadConfigEnvVars(){ env.BUILD_GENERATOR = isChangedOSSCode(["^generator/.*"]) + env.BUILD_ELASTIC_AGENT_XPACK = isChangedXPackCode([ + "^x-pack/elastic-agent/.*", + ]) + env.GO_VERSION = readFile(".go-version").trim() } diff --git a/Makefile b/Makefile index 64a97a8bdba..d99caea10a5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BUILD_DIR=$(CURDIR)/build COVERAGE_DIR=$(BUILD_DIR)/coverage -BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat x-pack/agent +BEATS?=auditbeat filebeat heartbeat journalbeat metricbeat packetbeat winlogbeat x-pack/functionbeat x-pack/elastic-agent PROJECTS=libbeat $(BEATS) PROJECTS_ENV=libbeat filebeat metricbeat PYTHON_ENV?=$(BUILD_DIR)/python-env diff --git a/dev-tools/packaging/packages.yml b/dev-tools/packaging/packages.yml index 3cda43b0f2c..c12c0549a1c 100644 --- a/dev-tools/packaging/packages.yml +++ b/dev-tools/packaging/packages.yml @@ -35,11 +35,11 @@ shared: content: > {{ commit }} mode: 0644 - /etc/{{.BeatName}}/agent.reference.yml: - source: 'agent.reference.yml' + /etc/{{.BeatName}}/elastic-agent.reference.yml: + source: 'elastic-agent.reference.yml' mode: 0644 - /etc/{{.BeatName}}/agent.yml: - source: 'agent.yml' + /etc/{{.BeatName}}/elastic-agent.yml: + source: 'elastic-agent.yml' mode: 0600 config: true /usr/share/{{.BeatName}}/bin/{{.BeatName}}-god: @@ -90,11 +90,11 @@ shared: /Library/Application Support/{{.BeatVendor}}/{{.BeatName}}/{{.identifier}}.plist: template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/darwin/launchd-daemon.plist.tmpl' mode: 0644 - /etc/{{.BeatName}}/agent.reference.yml: - source: 'agent.reference.yml' + /etc/{{.BeatName}}/elastic-agent.reference.yml: + source: 'elastic-agent.reference.yml' mode: 0644 - /etc/{{.BeatName}}/agent.yml: - source: 'agent.yml' + /etc/{{.BeatName}}/elastic-agent.yml: + source: 'elastic-agent.yml' mode: 0600 config: true /etc/{{.BeatName}}/data/downloads/filebeat-{{ beat_version }}-{{.GOOS}}-{{.AgentArchName}}.tar.gz: @@ -118,11 +118,11 @@ shared: content: > {{ commit }} mode: 0644 - 'agent.reference.yml': - source: 'agent.reference.yml' + 'elastic-agent.reference.yml': + source: 'elastic-agent.reference.yml' mode: 0644 - 'agent.yml': - source: 'agent.yml' + 'elastic-agent.yml': + source: 'elastic-agent.yml' mode: 0600 config: true @@ -163,8 +163,8 @@ shared: user: 'root' linux_capabilities: '' files: - 'agent.yml': - source: 'agent.docker.yml' + 'elastic-agent.yml': + source: 'elastic-agent.docker.yml' mode: 0600 config: true diff --git a/dev-tools/packaging/templates/docker/Dockerfile.agent.tmpl b/dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl similarity index 100% rename from dev-tools/packaging/templates/docker/Dockerfile.agent.tmpl rename to dev-tools/packaging/templates/docker/Dockerfile.elastic-agent.tmpl diff --git a/dev-tools/packaging/templates/docker/docker-entrypoint.agent.tmpl b/dev-tools/packaging/templates/docker/docker-entrypoint.elastic-agent.tmpl similarity index 100% rename from dev-tools/packaging/templates/docker/docker-entrypoint.agent.tmpl rename to dev-tools/packaging/templates/docker/docker-entrypoint.elastic-agent.tmpl diff --git a/libbeat/cmd/instance/beat.go b/libbeat/cmd/instance/beat.go index 10367a4dd29..af577325a99 100644 --- a/libbeat/cmd/instance/beat.go +++ b/libbeat/cmd/instance/beat.go @@ -629,7 +629,7 @@ func (b *Beat) configure(settings Settings) error { logp.Info("Beat ID: %v", b.Info.ID) // initialize config manager - b.ConfigManager, err = management.Factory()(b.Config.Management, reload.Register, b.Beat.Info.ID) + b.ConfigManager, err = management.Factory(b.Config.Management)(b.Config.Management, reload.Register, b.Beat.Info.ID) if err != nil { return err } diff --git a/libbeat/management/management.go b/libbeat/management/management.go index fb6c89ba870..dc793fafe2d 100644 --- a/libbeat/management/management.go +++ b/libbeat/management/management.go @@ -31,6 +31,8 @@ var Namespace = "libbeat.management" // DebugK used as key for all things central management var DebugK = "centralmgmt" +var centralMgmtKey = "x-pack-cm" + // ConfigManager interacts with the beat to update configurations // from an external source type ConfigManager interface { @@ -47,32 +49,47 @@ type ConfigManager interface { CheckRawConfig(cfg *common.Config) error } +// PluginFunc for creating FactoryFunc if it matches a config +type PluginFunc func(*common.Config) FactoryFunc + // FactoryFunc for creating a config manager type FactoryFunc func(*common.Config, *reload.Registry, uuid.UUID) (ConfigManager, error) // Register a config manager -func Register(name string, fn FactoryFunc, stability feature.Stability) { +func Register(name string, fn PluginFunc, stability feature.Stability) { f := feature.New(Namespace, name, fn, feature.MakeDetails(name, "", stability)) feature.MustRegister(f) } // Factory retrieves config manager constructor. If no one is registered // it will create a nil manager -func Factory() FactoryFunc { +func Factory(cfg *common.Config) FactoryFunc { factories, err := feature.GlobalRegistry().LookupAll(Namespace) if err != nil { return nilFactory } for _, f := range factories { - if factory, ok := f.Factory().(FactoryFunc); ok { - return factory + if plugin, ok := f.Factory().(PluginFunc); ok { + if factory := plugin(cfg); factory != nil { + return factory + } } } return nilFactory } +type modeConfig struct { + Mode string `config:"mode" yaml:"mode"` +} + +func defaultModeConfig() *modeConfig { + return &modeConfig{ + Mode: centralMgmtKey, + } +} + // nilManager, fallback when no manager is present type nilManager struct{} diff --git a/x-pack/agent/pkg/agent/application/configuration_embed.go b/x-pack/agent/pkg/agent/application/configuration_embed.go deleted file mode 100644 index 2276d1d3276..00000000000 --- a/x-pack/agent/pkg/agent/application/configuration_embed.go +++ /dev/null @@ -1,25 +0,0 @@ -// 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. - -// Code generated by dev-tools/cmd/buildfleetcfg/buildfleetcfg.go - DO NOT EDIT. - -package application - -import "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" - -// DefaultAgentFleetConfig is the content of the default configuration when we enroll a beat, the agent.yml -// will be replaced with this variables. -var DefaultAgentFleetConfig []byte - -func init() { - // Packed File - // _meta/agent.fleet.yml - unpacked := packer.MustUnpack("eJyMVV+Po74Vfe/H2A/wK3+G1VLp9xBnBmMW2IbM2NgvFbYzhsROUBMgUPW7VyZMZqYdVfsQRQJ8zz3nnnv8r2//MLtL9ddK7Y6XP171bnf5YzT629++ockJ//78ez/0JDU3eKRkUL975v7bnPboKdG0LCYE9YRg3nPDWubjkZGNkiQ4sBKpwlw1KzdnFOtebsGekgfFIDYVCTSCbi/8jRIediTUHfOzn2gERpjwguLixLYgrUhSc/Ok8MuhQ9F7DVmCAy0Lbb+rykwxo89sCxw+gj33AlMR6QrzoiSsNYpzLeOi5UZO9ntabixObd9zEzoozl0Rg14cC83WoNltAeQQa7l++MlJ1FEiNSe4k4+nn2gNLtwr9K9m1bAbt2at2gP3ZcdhWLP5m9UexXkvy2TPtqBnDXAq+KJomTgVYTX1iyldg5GVkVuViRYj0BxGk4R6j+C1rbwXJfxilCR3ZJloBKOOrUFHidtyIxT36I0XTFpuorEieFo3K4VGoFMjVOrLlpuil3522T0qLz22rVid1L0njLfb55NCpnZkDKZfzY/+U28Gn2mZOxXJOur96BkMfW6uPSXFlHq3macjWniCWkKlJPyx9FS0wuC9hOG4286zcCjRXUWCI4JFL73gzL3oYD0iYLSvvOjIyszq6tAyObKyeGVQj4zkDveTwOqcxJeBlsUpNUUtYRSm3nsdce+jaDnBvSw3iplw/Ig1Y8egpt6lZt7LjFURV3MfO7+a1ZTF2a0GZC2HL7Yvp1rPXqpRDFxqri0dwT9ZeVCyzK1HDPeRkgaPFWHBV9w+6rnMpmUN6Li/efNqK0YwCIMnRgIHweg4/8ey5XBQMk4CFBc9glb3jRIxbvjsj4vebZcdgZ/mpKSHG+Fph20fLMeB+cBU5Kq/1vD9rIByQOqk0DpTFQkmCaMzj8L5ewQLLbx8rMjs09nHHIZ7WhYt9x5mL97PQHx41xlPqQ9G7smREndKG5DI9cy55nHeo9jy3rzp3osGjIzcZ7Wcc5TwgaaeNhXJawl1z49ZZ/X87z6/5qg74Rc1h4Pd0UGYcM/KfPq1cOWzL92ar8HA/cRBMHC55dnc5it8UEsvsPO+n128eqlI8CpgOMrHk8qeV0P2uFq4uPUO6ou0vdv3a9BJ4jY2C2dfxvlAS9nN/o+Tnnp4Et5tfzmJHkrf5tDmO3rMbM1h8c7dr4tWe2FwPWfmCDpWik+10gb4FcTdTcdcCz9TNiPfso7Oz3IjyfVsd/RWCx8QnD0356mE+sJI6MrVTSurozhuFPeBFiZyKhJ299w/5i2Dt9ynW2Ao0WebW7b3RcPXez2r1wSmtWpHVhbj7nnJS4g7SpKzrcEgdliZWI2t5ywXp4J4RHGi572wuDav/byl5qrTBjwxwmpJrs6tJ2Y9plM75/e631FsM/VlyYu5VsvK/JV6ocuPmw9ew9MHL9j8nnu1z/8H6/HmRzSC7czHZp6PO7m251ZXBF1NSWDvyPtuU/OihMGOMNp6q+fzPaUvbAtqdixmTPuMmajlMR6Xfb73UHp5L0kwZ9eCfWDkWu+2YBIQ7yvCWmbvxDkfDqoiD4qXmaIGO9LDmv9/PoMYrG6FvZOCz/no1rso/BLLercirsu3915a3oCLGEHDysJnxPrxTfOsQ0+FZiZyebyZvZlNqwX3A8bzSeXEuWE/4QcBw85mZEWis+1PQjzaHbb40qu1vX9E845v8+rd29GE4Oca6ZID2NNOtZ553jWjJDigx+w+JzFZ367O6JEO6Xp1zfbgTfsvvWffsbIeuBdofixaSobv93fqzz+//fsv/wkAAP//30VSPA==") - raw, ok := unpacked["_meta/agent.fleet.yml"] - if !ok { - // ensure we have something loaded. - panic("agent.fleet.yml is not included in the binary") - } - DefaultAgentFleetConfig = raw -} diff --git a/x-pack/agent/pkg/agent/program/supported.go b/x-pack/agent/pkg/agent/program/supported.go deleted file mode 100644 index b6b8cbca19d..00000000000 --- a/x-pack/agent/pkg/agent/program/supported.go +++ /dev/null @@ -1,33 +0,0 @@ -// 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. - -// Code generated by x-pack/dev-tools/cmd/buildspec/buildspec.go - DO NOT EDIT. - -package program - -import ( - "strings" - - "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" -) - -var Supported []Spec -var SupportedMap map[string]bool - -func init() { - // Packed Files - // spec/filebeat.yml - // spec/metricbeat.yml - unpacked := packer.MustUnpack("eJzsV09zq7od3fdj3HWnD0RwS2fuwpCHgDjkGsdIaGdJCWBLhgnYGDr97h1hjLF9b/u67EwXGWIh/f6e3zniH9+q8oP99pmLD/qxqf/SSvHt79+odGvyXqSRFBVBgUjw8iUB+u4tt+UGnUQi44zPy4xJ3r3lNvVz3fXzJvX3oeBe3CykqOjKFFS6OYXx7gciGfVC0e+537uPBMV2leBILGR8SFBQEbS0iHQrBtb5wpnni/X5SZF7SBAXFMUH7pg1BZH4gdOaQXe7aXVJYSy441e+49fRSj2DOkFmRkBcE2RqU/vcC3SyCrgjwyOVpCRG3Pbv3ouUGEGTNGXL0UmwrnhZrOySylIkRvS5QeaO4HTm5PPUd2ztA9viLbcrCnjnpEXtw/iJe0Gm9lIoOu5aJYdxrez4zjz1PTvjMJ35MMo4dDuq/IK4G+z1e99yu6R7W+fe63AmOl7Xwo57gUiQPvjTM/Z8b1scmBdrzAg1JuOM4oudQKcw7t7SIlW/Fyt7Sw3bxEZ0xOBUMmM55HX+2+BI0Pci5Z5oyLIY14d4rnGcz9Q+DI/ME58cWufcL3E5N7k1TFpbgsOOGkE39cfh32a+d43ZybWU4Exj0t1y16o2ONQwEBpB+pgDg662eS7SDTIbjqOOGVFLkFuzprjJ4X6993WpU9P3uE7w/NLXJsFR8diHh/qp2A4MnDIO1ze1u8T1UDvVL88WbDutjVo/HYnxOuufzWS/M08JJoLul0ei5vG9SCm09lNfvmMLLtVMWB2HUUm3fb67DXq68xGDfg6MaMtUbDBsfmFHJ9585nvxjs1vY1G+FyA6JqBWOaQEWtsNiNs7OxUF7MhkvNvg8JOB05GD05F0RXpee33MvbW6DxyqcwoDpjpDmuKMASkqDuMWG4pHYnGdpVBQGG85tNqHXsFafNxhl0u34uimf8rfEIt2VzMt5ShqRmx70fZSi8XK3lEQfhHsX8/e5KVsia7vUz+jpKReJJiwQIJOOsGvF5x1RPGpER1VLS8YHt59Ebyb+XDkrCHnuxqoOBWXLXsM9/N8yY/sg6PC/p1djXZFX9MLt09rPM4ViCuCQk3N6KReE/4f144cRw3HyzGeDYhNpnKS6xcOMqHwuIJut1KziF+LANd04v9wiQ9jrfSdRPq/ZxnTzIyiuFPcTlbpnhqxpmY1aJs0AHGV4FDboLAjyG0TkO4Xznw/9GC/6GPjXwkiX8mKVb7De35WfLtxWOmk379/+/NZ+uRH/ZWzn4jfO4o1JsV2ELstRcuZD3XBvaBMwCCKONizrkhROwpOR3CkM8csKdQOBJlZIk+CPOsyQaeOrG7E6bJXEVpDoauR/ySaUs+odPcE6YoQDhRZO/KuPy2wnSWgqonyhZf/TjSv9nHUcrTO8bLcUmDKDeI669+tZz7kLYOvLwxavYDRfagl6FSdgaClFFmAxFYPhgs4rqSpfFq7Xjxbc7cwQgUGQVemSVGTj0ThReoCIfhzofI6Ei+uCH49EKcnAo0g7fCB9Goho5KBc8x++l+Jck1w1CqQ/F+Y/3eF+acCoFvGBkcFNgJBQPw01vknpM/keua7T4eX1hrxEMzvSc6/vwwobGsEB5/3ovGLM+ecQGy+5fY4YwN27ki/FxM1e31uFLnNr2o2nB8xPyH8jO7D/tKMDV5ymH0yGe8JzprrPE5w50Umg+tpz1vFcThPf1s/n/p5+ZE/fb2sHmt0tqN8pDPfifq91zwCMfDl1LZk0lJ4mu6d9HaY9eWI9TpBtcDAbZl0zZv4ocKUduVdIxR8/oD3MWYy1myI7cxTvZDezM+5T5Nzy6mQ19QgAoMeS9O8fi7If+jMmVPIILYJsJpxHyQtBdoDloZa3eiNOsv6jxhd3Is8neqV0p9HnlIfTD3P3FxKto+XqSnWbuz+QdF39rwg6Gl2FvIzL7w48V8RuMnnMOqErlsvq7kMcttPcPim8mOG0rR1EQBL556tc6cXckGh23EotgzEGZNhEbSNiuEq/s58vwGu3IDf+//VJYwZUcZAun9ZFt+//fNP/woAAP//ypoPSg==") - SupportedMap = make(map[string]bool) - - for f, v := range unpacked { - s, err := NewSpecFromBytes(v) - if err != nil { - panic("Cannot read spec from " + f) - } - Supported = append(Supported, s) - SupportedMap[strings.ToLower(s.Name)] = true - } -} diff --git a/x-pack/agent/.gitignore b/x-pack/elastic-agent/.gitignore similarity index 93% rename from x-pack/agent/.gitignore rename to x-pack/elastic-agent/.gitignore index 8ec1b138bbd..cf53b23c7ec 100644 --- a/x-pack/agent/.gitignore +++ b/x-pack/elastic-agent/.gitignore @@ -1,6 +1,6 @@ # agent build/ -agent.dev.yml +elastic-agent.dev.yml pkg/agent/operation/tests/scripts/short--1.0.yml pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/configurable pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/configurablebyfile diff --git a/x-pack/agent/CHANGELOG.asciidoc b/x-pack/elastic-agent/CHANGELOG.asciidoc similarity index 83% rename from x-pack/agent/CHANGELOG.asciidoc rename to x-pack/elastic-agent/CHANGELOG.asciidoc index 6cafa5bbf9a..63190e42d5e 100644 --- a/x-pack/agent/CHANGELOG.asciidoc +++ b/x-pack/elastic-agent/CHANGELOG.asciidoc @@ -9,11 +9,14 @@ ==== Breaking changes +- Rename agent to elastic-agent {pull}17391[17391] ==== Bugfixes - Fixed tests on windows {pull}16922[16922] - Fixed installers for SNAPSHOTs and windows {pull}17077[17077] +- Fixed merge of config {pull}17399[17399] +- Handle abs paths on windows correctly {pull}17461[17461] ==== New features diff --git a/x-pack/agent/Dockerfile b/x-pack/elastic-agent/Dockerfile similarity index 100% rename from x-pack/agent/Dockerfile rename to x-pack/elastic-agent/Dockerfile diff --git a/x-pack/agent/Makefile b/x-pack/elastic-agent/Makefile similarity index 100% rename from x-pack/agent/Makefile rename to x-pack/elastic-agent/Makefile diff --git a/x-pack/agent/_meta/common.p1.yml b/x-pack/elastic-agent/_meta/common.p1.yml similarity index 71% rename from x-pack/agent/_meta/common.p1.yml rename to x-pack/elastic-agent/_meta/common.p1.yml index 6c9a9f190e7..0e94bd3c074 100644 --- a/x-pack/agent/_meta/common.p1.yml +++ b/x-pack/elastic-agent/_meta/common.p1.yml @@ -1,5 +1,5 @@ ###################### Agent Configuration Example ######################### # This file is an example configuration file highlighting only the most common -# options. The agent.reference.yml file from the same directory contains all the +# options. The elastic-agent.reference.yml file from the same directory contains all the # supported options with more comments. You can use it as a reference. diff --git a/x-pack/agent/_meta/common.p2.yml b/x-pack/elastic-agent/_meta/common.p2.yml similarity index 93% rename from x-pack/agent/_meta/common.p2.yml rename to x-pack/elastic-agent/_meta/common.p2.yml index 2fc2da9071e..0ff0776250e 100644 --- a/x-pack/agent/_meta/common.p2.yml +++ b/x-pack/elastic-agent/_meta/common.p2.yml @@ -24,9 +24,9 @@ datasources: dataset: system.filesystem management: - # Mode of magement, the agent support two modes of operation: + # Mode of management, the Elastic Agent support two modes of operation: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: "local" @@ -65,7 +65,7 @@ management: # Allow fleet to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true diff --git a/x-pack/agent/_meta/common.reference.p1.yml b/x-pack/elastic-agent/_meta/common.reference.p1.yml similarity index 71% rename from x-pack/agent/_meta/common.reference.p1.yml rename to x-pack/elastic-agent/_meta/common.reference.p1.yml index 6c9a9f190e7..0e94bd3c074 100644 --- a/x-pack/agent/_meta/common.reference.p1.yml +++ b/x-pack/elastic-agent/_meta/common.reference.p1.yml @@ -1,5 +1,5 @@ ###################### Agent Configuration Example ######################### # This file is an example configuration file highlighting only the most common -# options. The agent.reference.yml file from the same directory contains all the +# options. The elastic-agent.reference.yml file from the same directory contains all the # supported options with more comments. You can use it as a reference. diff --git a/x-pack/agent/_meta/common.reference.p2.yml b/x-pack/elastic-agent/_meta/common.reference.p2.yml similarity index 93% rename from x-pack/agent/_meta/common.reference.p2.yml rename to x-pack/elastic-agent/_meta/common.reference.p2.yml index 97ac70329c3..b27d681bfb9 100644 --- a/x-pack/agent/_meta/common.reference.p2.yml +++ b/x-pack/elastic-agent/_meta/common.reference.p2.yml @@ -24,9 +24,9 @@ datasources: dataset: system.filesystem management: - # Mode of management, the agent currently only support the following mode: + # Mode of management, the Elastic Agent currently only support the following mode: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: local @@ -65,7 +65,7 @@ management: # Allow fleet to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true diff --git a/x-pack/agent/_meta/agent.docker.yml b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml similarity index 86% rename from x-pack/agent/_meta/agent.docker.yml rename to x-pack/elastic-agent/_meta/elastic-agent.docker.yml index 07f764269b0..07dec01f4a1 100644 --- a/x-pack/agent/_meta/agent.docker.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.docker.yml @@ -24,9 +24,9 @@ datasources: dataset: system.filesystem management: - # Mode of management, the agent support two modes of operation: + # Mode of management, the Elastic Agent support two modes of operation: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: "local" @@ -36,10 +36,10 @@ management: # format in which logs will be written, options are json or default. format: "default" - # Allow the agent to reload his configuration locally on disk. + # Allow the Elastic Agent to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true @@ -56,7 +56,7 @@ download: # timeout for downloading package timeout: 30s # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. + # if not file is present Elastic Agent will try to load public key from elastic.co website. pgpfile: "${path.data}/elastic.pgp" # install_path describes the location of installed packages/programs. It is also used # for reading program specifications. diff --git a/x-pack/agent/_meta/agent.fleet.yml b/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml similarity index 94% rename from x-pack/agent/_meta/agent.fleet.yml rename to x-pack/elastic-agent/_meta/elastic-agent.fleet.yml index 883f1c35835..08304cbaa92 100644 --- a/x-pack/agent/_meta/agent.fleet.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.fleet.yml @@ -14,7 +14,7 @@ download: # timeout for downloading package timeout: 30s # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. + # if not file is present Elastic Agent will try to load public key from elastic.co website. pgpfile: "${path.data}/elastic.pgp" # install_path describes the location of installed packages/programs. It is also used # for reading program specifications. diff --git a/x-pack/agent/_meta/agent.yml b/x-pack/elastic-agent/_meta/elastic-agent.yml similarity index 86% rename from x-pack/agent/_meta/agent.yml rename to x-pack/elastic-agent/_meta/elastic-agent.yml index c17c32405e1..e0f7acc636d 100644 --- a/x-pack/agent/_meta/agent.yml +++ b/x-pack/elastic-agent/_meta/elastic-agent.yml @@ -24,9 +24,9 @@ datasources: dataset: system.filesystem management: - # Mode of management, the agent support two modes of operation: + # Mode of management, the Elastic Agent support two modes of operation: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: "local" @@ -37,10 +37,10 @@ management: # format in which logs will be written, options are json or default. format: "default" - # Allow the agent to reload his configuration locally on disk. + # Allow the Elastic Agent to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true @@ -57,7 +57,7 @@ download: # timeout for downloading package timeout: 30s # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. + # if not file is present Elastic Agent will try to load public key from elastic.co website. pgpfile: "${path.data}/elastic.pgp" # install_path describes the location of installed packages/programs. It is also used # for reading program specifications. diff --git a/x-pack/agent/cmd/agent/agent.go b/x-pack/elastic-agent/cmd/elastic-agent/elastic-agent.go similarity index 89% rename from x-pack/agent/cmd/agent/agent.go rename to x-pack/elastic-agent/cmd/elastic-agent/elastic-agent.go index 6b1301ee388..dd33de56575 100644 --- a/x-pack/agent/cmd/agent/agent.go +++ b/x-pack/elastic-agent/cmd/elastic-agent/elastic-agent.go @@ -10,7 +10,7 @@ import ( "os" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/cmd" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/cmd" ) // main just a wrapper, all commands are defined in 'pkg/agent/cmd'. diff --git a/x-pack/agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go b/x-pack/elastic-agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go similarity index 87% rename from x-pack/agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go rename to x-pack/elastic-agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go index 4987fffcce9..b1d6946cff7 100644 --- a/x-pack/agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go +++ b/x-pack/elastic-agent/dev-tools/cmd/buildfleetcfg/buildfleetcfg.go @@ -14,7 +14,7 @@ import ( "text/template" "github.com/elastic/beats/v7/licenses" - "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" ) var ( @@ -35,9 +35,9 @@ var tmpl = template.Must(template.New("cfg").Parse(` package application -import "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" +import "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" -// DefaultAgentFleetConfig is the content of the default configuration when we enroll a beat, the agent.yml +// DefaultAgentFleetConfig is the content of the default configuration when we enroll a beat, the elastic-agent.yml // will be replaced with this variables. var DefaultAgentFleetConfig []byte @@ -47,10 +47,10 @@ func init() { // {{ $f }} {{ end -}} unpacked := packer.MustUnpack("{{ .Pack }}") - raw, ok := unpacked["_meta/agent.fleet.yml"] + raw, ok := unpacked["_meta/elastic-agent.fleet.yml"] if !ok { // ensure we have something loaded. - panic("agent.fleet.yml is not included in the binary") + panic("elastic-agent.fleet.yml is not included in the binary") } DefaultAgentFleetConfig = raw } diff --git a/x-pack/agent/dev-tools/cmd/buildspec/buildspec.go b/x-pack/elastic-agent/dev-tools/cmd/buildspec/buildspec.go similarity index 94% rename from x-pack/agent/dev-tools/cmd/buildspec/buildspec.go rename to x-pack/elastic-agent/dev-tools/cmd/buildspec/buildspec.go index 7cef6ef9a72..980c3d90d33 100644 --- a/x-pack/agent/dev-tools/cmd/buildspec/buildspec.go +++ b/x-pack/elastic-agent/dev-tools/cmd/buildspec/buildspec.go @@ -14,7 +14,7 @@ import ( "text/template" "github.com/elastic/beats/v7/licenses" - "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" ) var ( @@ -38,7 +38,7 @@ package program import ( "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/packer" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" ) var Supported []Spec diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/README.md b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/README.md similarity index 93% rename from x-pack/agent/dev-tools/cmd/fakewebapi/README.md rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/README.md index 23853de9a5c..43def1b4cc7 100644 --- a/x-pack/agent/dev-tools/cmd/fakewebapi/README.md +++ b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/README.md @@ -1,6 +1,6 @@ Fakewebapi is a simple test only Webserver -The server implements the minimal calls and response to do high level testing of the agent: +The server implements the minimal calls and response to do high level testing of the elastic-agent: - Enroll successfully an Agent. - Allow an Agent to periodically check in. diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/action_example.json b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/action_example.json similarity index 100% rename from x-pack/agent/dev-tools/cmd/fakewebapi/action_example.json rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/action_example.json diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/checkin.json b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/checkin.json similarity index 100% rename from x-pack/agent/dev-tools/cmd/fakewebapi/checkin.json rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/checkin.json diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/fetch.sh b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/fetch.sh similarity index 100% rename from x-pack/agent/dev-tools/cmd/fakewebapi/fetch.sh rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/fetch.sh diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/main.go b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/main.go similarity index 98% rename from x-pack/agent/dev-tools/cmd/fakewebapi/main.go rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/main.go index 27611b78467..3a40641678a 100644 --- a/x-pack/agent/dev-tools/cmd/fakewebapi/main.go +++ b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/main.go @@ -18,7 +18,7 @@ import ( "sync" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) var ( diff --git a/x-pack/agent/dev-tools/cmd/fakewebapi/push.sh b/x-pack/elastic-agent/dev-tools/cmd/fakewebapi/push.sh similarity index 100% rename from x-pack/agent/dev-tools/cmd/fakewebapi/push.sh rename to x-pack/elastic-agent/dev-tools/cmd/fakewebapi/push.sh diff --git a/x-pack/agent/docker-compose.yml b/x-pack/elastic-agent/docker-compose.yml similarity index 100% rename from x-pack/agent/docker-compose.yml rename to x-pack/elastic-agent/docker-compose.yml diff --git a/x-pack/agent/docs/agent.asciidoc b/x-pack/elastic-agent/docs/elastic-agent.asciidoc similarity index 100% rename from x-pack/agent/docs/agent.asciidoc rename to x-pack/elastic-agent/docs/elastic-agent.asciidoc diff --git a/x-pack/agent/docs/agent_configuration_example.yml b/x-pack/elastic-agent/docs/elastic-agent_configuration_example.yml similarity index 100% rename from x-pack/agent/docs/agent_configuration_example.yml rename to x-pack/elastic-agent/docs/elastic-agent_configuration_example.yml diff --git a/x-pack/agent/agent.docker.yml b/x-pack/elastic-agent/elastic-agent.docker.yml similarity index 86% rename from x-pack/agent/agent.docker.yml rename to x-pack/elastic-agent/elastic-agent.docker.yml index 07f764269b0..07dec01f4a1 100644 --- a/x-pack/agent/agent.docker.yml +++ b/x-pack/elastic-agent/elastic-agent.docker.yml @@ -24,9 +24,9 @@ datasources: dataset: system.filesystem management: - # Mode of management, the agent support two modes of operation: + # Mode of management, the Elastic Agent support two modes of operation: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: "local" @@ -36,10 +36,10 @@ management: # format in which logs will be written, options are json or default. format: "default" - # Allow the agent to reload his configuration locally on disk. + # Allow the Elastic Agent to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true @@ -56,7 +56,7 @@ download: # timeout for downloading package timeout: 30s # file path to a public key used for verifying downloaded artifacts - # if not file is present agent will try to load public key from elastic.co website. + # if not file is present Elastic Agent will try to load public key from elastic.co website. pgpfile: "${path.data}/elastic.pgp" # install_path describes the location of installed packages/programs. It is also used # for reading program specifications. diff --git a/x-pack/agent/agent.reference.yml b/x-pack/elastic-agent/elastic-agent.reference.yml similarity index 91% rename from x-pack/agent/agent.reference.yml rename to x-pack/elastic-agent/elastic-agent.reference.yml index 53cb79b40b5..7b1ee5cca98 100644 --- a/x-pack/agent/agent.reference.yml +++ b/x-pack/elastic-agent/elastic-agent.reference.yml @@ -1,7 +1,7 @@ ###################### Agent Configuration Example ######################### # This file is an example configuration file highlighting only the most common -# options. The agent.reference.yml file from the same directory contains all the +# options. The elastic-agent.reference.yml file from the same directory contains all the # supported options with more comments. You can use it as a reference. ###################################### # Fleet configuration @@ -29,9 +29,9 @@ datasources: dataset: system.filesystem management: - # Mode of management, the agent currently only support the following mode: + # Mode of management, the Elastic Agent currently only support the following mode: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: local @@ -70,7 +70,7 @@ management: # Allow fleet to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true diff --git a/x-pack/agent/agent.yml b/x-pack/elastic-agent/elastic-agent.yml similarity index 91% rename from x-pack/agent/agent.yml rename to x-pack/elastic-agent/elastic-agent.yml index ac4ed658ced..a5fd150155b 100644 --- a/x-pack/agent/agent.yml +++ b/x-pack/elastic-agent/elastic-agent.yml @@ -1,7 +1,7 @@ ###################### Agent Configuration Example ######################### # This file is an example configuration file highlighting only the most common -# options. The agent.reference.yml file from the same directory contains all the +# options. The elastic-agent.reference.yml file from the same directory contains all the # supported options with more comments. You can use it as a reference. ###################################### # Fleet configuration @@ -29,9 +29,9 @@ datasources: dataset: system.filesystem management: - # Mode of magement, the agent support two modes of operation: + # Mode of management, the Elastic Agent support two modes of operation: # - # local: The agent will expect to find the inputs configuration in the local file. + # local: The Elastic Agent will expect to find the inputs configuration in the local file. # # Default is local. mode: "local" @@ -70,7 +70,7 @@ management: # Allow fleet to reload his configuration locally on disk. # Notes: Only specific process configuration will be reloaded. reload: - # enabled configure the agent to reload or not the local configuration. + # enabled configure the Elastic Agent to reload or not the local configuration. # # Default is true enabled: true diff --git a/x-pack/agent/magefile.go b/x-pack/elastic-agent/magefile.go similarity index 91% rename from x-pack/agent/magefile.go rename to x-pack/elastic-agent/magefile.go index a9934e941a1..deb05fd4d40 100644 --- a/x-pack/agent/magefile.go +++ b/x-pack/elastic-agent/magefile.go @@ -22,7 +22,7 @@ import ( devtools "github.com/elastic/beats/v7/dev-tools/mage" "github.com/elastic/beats/v7/dev-tools/mage/target/common" "github.com/elastic/beats/v7/dev-tools/mage/target/unittest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" // mage:import _ "github.com/elastic/beats/v7/dev-tools/mage/target/common" @@ -37,6 +37,7 @@ const ( buildDir = "build" metaDir = "_meta" snapshotEnv = "SNAPSHOT" + configFile = "elastic-agent.yml" ) // Aliases for commands required by master makefile @@ -91,17 +92,17 @@ func (Build) All() { mg.Deps(Build.Binary) } -// GenerateConfig generates the configuration from _meta/agent.yml +// GenerateConfig generates the configuration from _meta/elastic-agent.yml func (Build) GenerateConfig() error { mg.Deps(Mkdir(buildDir)) - return sh.Copy(filepath.Join(buildDir, "agent.yml"), filepath.Join(metaDir, "agent.yml")) + return sh.Copy(filepath.Join(buildDir, configFile), filepath.Join(metaDir, configFile)) } // GolangCrossBuildOSS build the Beat binary inside of the golang-builder. // Do not use directly, use crossBuild instead. func GolangCrossBuildOSS() error { params := devtools.DefaultGolangCrossBuildArgs() - params.InputFiles = []string{"cmd/agent/agent.go"} + params.InputFiles = []string{"cmd/elastic-agent/elastic-agent.go"} params.LDFlags = flagsSet() return devtools.GolangCrossBuild(params) } @@ -110,7 +111,7 @@ func GolangCrossBuildOSS() error { // Do not use directly, use crossBuild instead. func GolangCrossBuild() error { params := devtools.DefaultGolangCrossBuildArgs() - params.InputFiles = []string{"cmd/agent/agent.go"} + params.InputFiles = []string{"cmd/elastic-agent/elastic-agent.go"} params.OutputDir = "build/golang-crossbuild" params.LDFlags = flagsSet() if err := devtools.GolangCrossBuild(params); err != nil { @@ -133,9 +134,9 @@ func (Build) BinaryOSS() error { mg.Deps(Prepare.Env) return RunGo( "build", - "-o", filepath.Join(buildDir, "agent-oss"), + "-o", filepath.Join(buildDir, "elastic-agent-oss"), "-ldflags", flags(), - "cmd/agent/agent.go", + "cmd/elastic-agent/elastic-agent.go", ) } @@ -144,9 +145,9 @@ func (Build) Binary() error { mg.Deps(Prepare.Env) return RunGo( "build", - "-o", filepath.Join(buildDir, "agent"), + "-o", filepath.Join(buildDir, "elastic-agent"), "-ldflags", flags(), - "cmd/agent/agent.go", + "cmd/elastic-agent/elastic-agent.go", ) } @@ -156,9 +157,9 @@ func (Build) Dev() error { return RunGo( "build", "-tags", "dev", - "-o", filepath.Join(buildDir, "agent"), + "-o", filepath.Join(buildDir, "elastic-agent"), "-ldflags", flags(), - "cmd/agent/agent.go", + "cmd/elastic-agent/elastic-agent.go", ) } @@ -366,9 +367,9 @@ func flagsSet() []string { isSnapshot, _ := os.LookupEnv(snapshotEnv) return []string{ - fmt.Sprintf(`-X "github.com/elastic/beats/v7/x-pack/agent/pkg/release.buildTime=%s"`, ts), - fmt.Sprintf(`-X "github.com/elastic/beats/v7/x-pack/agent/pkg/release.commit=%s"`, commitID), - fmt.Sprintf(` -X "github.com/elastic/beats/v7/x-pack/agent/pkg/release.snapshot=%s"`, isSnapshot), + fmt.Sprintf(`-X "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release.buildTime=%s"`, ts), + fmt.Sprintf(`-X "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release.commit=%s"`, commitID), + fmt.Sprintf(` -X "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release.snapshot=%s"`, isSnapshot), } } @@ -419,7 +420,7 @@ func ConfigFileParams() devtools.ConfigFileParams { devtools.XPackBeatDir("_meta/common.reference.p2.yml"), }, DockerParts: []string{ - devtools.XPackBeatDir("_meta/agent.docker.yml"), + devtools.XPackBeatDir("_meta/elastic-agent.docker.yml"), }, } } @@ -468,7 +469,7 @@ func IntegTest() { // BuildFleetCfg embed the default fleet configuration as part of the binary. func BuildFleetCfg() error { goF := filepath.Join("dev-tools", "cmd", "buildfleetcfg", "buildfleetcfg.go") - in := filepath.Join("_meta", "agent.fleet.yml") + in := filepath.Join("_meta", "elastic-agent.fleet.yml") out := filepath.Join("pkg", "agent", "application", "configuration_embed.go") fmt.Printf(">> BuildFleetCfg %s to %s\n", in, out) diff --git a/x-pack/agent/main.go b/x-pack/elastic-agent/main.go similarity index 88% rename from x-pack/agent/main.go rename to x-pack/elastic-agent/main.go index db421a72f16..f9bf84484ac 100644 --- a/x-pack/agent/main.go +++ b/x-pack/elastic-agent/main.go @@ -10,7 +10,7 @@ import ( "os" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/cmd" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/cmd" ) // Setups and Runs agent. diff --git a/x-pack/agent/main_test.go b/x-pack/elastic-agent/main_test.go similarity index 100% rename from x-pack/agent/main_test.go rename to x-pack/elastic-agent/main_test.go diff --git a/x-pack/agent/pkg/agent/application/action_dispatcher.go b/x-pack/elastic-agent/pkg/agent/application/action_dispatcher.go similarity index 92% rename from x-pack/agent/pkg/agent/application/action_dispatcher.go rename to x-pack/elastic-agent/pkg/agent/application/action_dispatcher.go index e37c54683bd..833f9a98476 100644 --- a/x-pack/agent/pkg/agent/application/action_dispatcher.go +++ b/x-pack/elastic-agent/pkg/agent/application/action_dispatcher.go @@ -10,9 +10,9 @@ import ( "reflect" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) type action = fleetapi.Action diff --git a/x-pack/agent/pkg/agent/application/action_dispatcher_test.go b/x-pack/elastic-agent/pkg/agent/application/action_dispatcher_test.go similarity index 100% rename from x-pack/agent/pkg/agent/application/action_dispatcher_test.go rename to x-pack/elastic-agent/pkg/agent/application/action_dispatcher_test.go diff --git a/x-pack/agent/pkg/agent/application/action_store.go b/x-pack/elastic-agent/pkg/agent/application/action_store.go similarity index 97% rename from x-pack/agent/pkg/agent/application/action_store.go rename to x-pack/elastic-agent/pkg/agent/application/action_store.go index 11260fa6daa..2da8d3c0a8f 100644 --- a/x-pack/agent/pkg/agent/application/action_store.go +++ b/x-pack/elastic-agent/pkg/agent/application/action_store.go @@ -10,8 +10,8 @@ import ( yaml "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) // actionStore receives multiples actions to persist to disk, the implementation of the store only diff --git a/x-pack/agent/pkg/agent/application/action_store_test.go b/x-pack/elastic-agent/pkg/agent/application/action_store_test.go similarity index 93% rename from x-pack/agent/pkg/agent/application/action_store_test.go rename to x-pack/elastic-agent/pkg/agent/application/action_store_test.go index 5859b59ba69..02e62efd1a4 100644 --- a/x-pack/agent/pkg/agent/application/action_store_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/action_store_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/storage" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/storage" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) func TestActionStore(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/application/application.go b/x-pack/elastic-agent/pkg/agent/application/application.go similarity index 77% rename from x-pack/agent/pkg/agent/application/application.go rename to x-pack/elastic-agent/pkg/agent/application/application.go index d2e3e4f72e5..78634055989 100644 --- a/x-pack/agent/pkg/agent/application/application.go +++ b/x-pack/elastic-agent/pkg/agent/application/application.go @@ -7,11 +7,11 @@ package application import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/warn" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/warn" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // Application is the application interface implemented by the different running mode. @@ -24,8 +24,8 @@ type Application interface { // New creates a new Agent and bootstrap the required subsystem. func New(log *logger.Logger, pathConfigFile string) (Application, error) { // Load configuration from disk to understand in which mode of operation - // we must start the agent, the mode of operation cannot be changed without restarting the - // agent. + // we must start the elastic-agent, the mode of operation cannot be changed without restarting the + // elastic-agent. config, err := config.LoadYAML(pathConfigFile) if err != nil { return nil, err diff --git a/x-pack/agent/pkg/agent/application/application_test.go b/x-pack/elastic-agent/pkg/agent/application/application_test.go similarity index 100% rename from x-pack/agent/pkg/agent/application/application_test.go rename to x-pack/elastic-agent/pkg/agent/application/application_test.go diff --git a/x-pack/agent/pkg/agent/application/config.go b/x-pack/elastic-agent/pkg/agent/application/config.go similarity index 88% rename from x-pack/agent/pkg/agent/application/config.go rename to x-pack/elastic-agent/pkg/agent/application/config.go index c9a1488ce79..edec6b4c7f8 100644 --- a/x-pack/agent/pkg/agent/application/config.go +++ b/x-pack/elastic-agent/pkg/agent/application/config.go @@ -8,12 +8,12 @@ import ( "fmt" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" - fleetreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/fleet" - logreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/log" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "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/beats/v7/x-pack/elastic-agent/pkg/kibana" + fleetreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/fleet" + logreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/log" ) // TODO(ph) correctly setup global path. @@ -109,7 +109,7 @@ func localConfigDefault() *localConfig { } // FleetAgentConfig is the internal configuration of the agent after the enrollment is done, -// this configuration is not exposed in anyway in the agent.yml and is only internal configuration. +// this configuration is not exposed in anyway in the elastic-agent.yml and is only internal configuration. type FleetAgentConfig struct { API *APIAccess `config:"api" yaml:"api"` Reporting *LogReporting `config:"reporting" yaml:"reporting"` diff --git a/x-pack/agent/pkg/agent/application/config_request.go b/x-pack/elastic-agent/pkg/agent/application/config_request.go similarity index 93% rename from x-pack/agent/pkg/agent/application/config_request.go rename to x-pack/elastic-agent/pkg/agent/application/config_request.go index 52e8cd3b4cd..ae3c067429f 100644 --- a/x-pack/agent/pkg/agent/application/config_request.go +++ b/x-pack/elastic-agent/pkg/agent/application/config_request.go @@ -8,7 +8,7 @@ import ( "strings" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" ) const shortID = 8 diff --git a/x-pack/agent/pkg/agent/application/config_request_test.go b/x-pack/elastic-agent/pkg/agent/application/config_request_test.go similarity index 100% rename from x-pack/agent/pkg/agent/application/config_request_test.go rename to x-pack/elastic-agent/pkg/agent/application/config_request_test.go diff --git a/x-pack/agent/pkg/agent/application/config_test.go b/x-pack/elastic-agent/pkg/agent/application/config_test.go similarity index 96% rename from x-pack/agent/pkg/agent/application/config_test.go rename to x-pack/elastic-agent/pkg/agent/application/config_test.go index c1cd3e29459..688f3d3ed02 100644 --- a/x-pack/agent/pkg/agent/application/config_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/config_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" ) func TestConfig(t *testing.T) { diff --git a/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go b/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go new file mode 100644 index 00000000000..8a064cf9268 --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/application/configuration_embed.go @@ -0,0 +1,25 @@ +// 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. + +// Code generated by dev-tools/cmd/buildfleetcfg/buildfleetcfg.go - DO NOT EDIT. + +package application + +import "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" + +// DefaultAgentFleetConfig is the content of the default configuration when we enroll a beat, the elastic-agent.yml +// will be replaced with this variables. +var DefaultAgentFleetConfig []byte + +func init() { + // Packed File + // _meta/elastic-agent.fleet.yml + unpacked := packer.MustUnpack("eJyMlk2Xo7oRhvf5GbPPDR/NnCE7CzdCjKFjfFtfmxwkeQS2ZHNigw05+e85wm53z6Rzz130xkh6q956qqr//eWfdnuu/7Y19encyr/Wens4//bDbLfn30Zrvvz9C5q8+B+//7k/9KyMsHhk5KL/7J3H3/q4Q8+5YbSaEDQTguUgLO94iEdO1lqRaM8p0pW9Gk7XJ5SZQW3AjpEnzSG2NYkMgv4gw7WWAfYUND0Pi+9oBFba+Iyy6sg3YFWTvBH2WePXfY/S9zcUBXtGK+PO1bTQ3JoT3wBPjGAngsjWRPnSvmoFG4Oy0qis6oRVkzvP6NrpNO67sLGHstKXGRjkoTI8Ae12A6CA2Kjk6bsgac+IMoLgXi2P31ECziKozEu7aPkttzbR3V6Eqhcwbvh8ZrFDWTkomu/4Bgy8BV4NXzWjuVcT3rCwmlYJGDlN/ZrmRo7ACJhOCpodgteuDl61DKtRkdJTNDcIpj1PQM+I3wkrtQjYLS+Yd8KmY03wlLQLjUZgVlbqVag6YatBhcV5u9TB6tB1cnHUj5gw3mx+P2pkG09lYHppvw0/xWbxidHSq0nRs+DbwGEcCnsdGKmmVXCr+WpE9zxBo6DWCn67x1R10uKdgvG43cy18BgxfU2iA4LVoILoJIJ07xiRMN3VQXrgtHC+eozmB06rHxyakZPSE2EeOZ/z7HxhtDqubNUomMar4P0d+Yij6gTBg6JrzW08ftSatTPQsODc8OB11qqJb0SIvZd2MRVZcXsD8k7AVxeXVyczSw3KgM/stWMj+Bene61o6RixIkRaWTzWhEef5fbRz3ttOt6CXoTrN1Y7OYKLtHjiJPLQ88NzvXa8HdZaBeYkEuDJw372d+YrARdF8pM7Vwc4QpCPIvA0J9dGhlXHxmgnRhBykk81rcxKu7qDg7zl9hUlaL8N55r1HKYeo97w4e6Fh4v2LV5xKD1Grid6O+/6dmJh3jGLp3t/nkRQNgqaQbQz5487v9R3kFk+8DBvBC169Gy828xITzL4dvPU8ZkUt9pluWGkmll/3NuASUK8qwnvWJB6NYl7OT65Wv4a56c51iSaFExPIkHfkwMYRVAaGRZf77meaxJ1gqQnNM+BtRYHfGYWjwjyQbZOOw2FxXuUvd0tjbwcNYJ+J0x8EWHuWLoWy8WluOciSPpUE98XGzB/RzDyBcmNbG/8SBdjEDmeLtLGO07L6d4LZ0abHxLGo1oedTEtLsVy8X84L0dOnB+Owcio8ae3epSpIydPs48swJMcZ+5mDmWId/NvAfcFvEZvb838zsw17uyjV+5eOR9HlYBBQjwyWnUieNJuBrMg7mVg9pzmLqcGQd7U5OrmsMvp5qGJ/6f3kkNuVJZHL/rOAIka5mZrAvacVkZaN/ccc+rIaXV0e0VaPPeF05UwnmRgWgFfe/RcGW5TX2RrfdsLjrHX3sX+eHd51CrLfb6+6c1vWWOkH+9EiHuVvLPGafGBhdg6NlWWd7O3v2gVM4+LHUpv+bidqFxvu3vLZy0IbsSh0DV99HbLN24PVG6G7xGMe7fDnD8IplbBWdP9ZhkxJ7cLbv38FkP5gwWxLw7rr2j5NsMqt0silJUXTsqOu7xGsHc9vt2ATrTgLEfQclqFnOD+D/OZwDy7OHSzae80LjPzd7Zp8KmWY7cTFJ8fsUDTI+hPCDotZWYe3zwfn3QFsWUUn1Ti2FxMxfKm+1HjpV344l6vijYXEURGHKrO/e/CIfY4zV0PO/2whtirZ+8e+m5evbPtuPj5jf7ONq1pdZzzfPesEXati/FRp2nmNrnocrc4oeXz+Ngfn7Pn2DfbDAzC4l5B04jl8fHty3/+8t8AAAD///ycVl0=") + raw, ok := unpacked["_meta/elastic-agent.fleet.yml"] + if !ok { + // ensure we have something loaded. + panic("elastic-agent.fleet.yml is not included in the binary") + } + DefaultAgentFleetConfig = raw +} diff --git a/x-pack/agent/pkg/agent/application/emitter.go b/x-pack/elastic-agent/pkg/agent/application/emitter.go similarity index 85% rename from x-pack/agent/pkg/agent/application/emitter.go rename to x-pack/elastic-agent/pkg/agent/application/emitter.go index 4d3c0181987..2e4c07bf0dd 100644 --- a/x-pack/agent/pkg/agent/application/emitter.go +++ b/x-pack/elastic-agent/pkg/agent/application/emitter.go @@ -7,11 +7,11 @@ package application import ( "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "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" ) type decoratorFunc = func(string, *transpiler.AST, []program.Program) ([]program.Program, error) diff --git a/x-pack/agent/pkg/agent/application/enroll_cmd.go b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go similarity index 90% rename from x-pack/agent/pkg/agent/application/enroll_cmd.go rename to x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go index bfcbf09e03f..b1743e92417 100644 --- a/x-pack/agent/pkg/agent/application/enroll_cmd.go +++ b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd.go @@ -14,12 +14,12 @@ import ( "gopkg.in/yaml.v2" "github.com/elastic/beats/v7/libbeat/common/transport/tlscommon" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/storage" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/storage" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" ) type store interface { diff --git a/x-pack/agent/pkg/agent/application/enroll_cmd_test.go b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go similarity index 97% rename from x-pack/agent/pkg/agent/application/enroll_cmd_test.go rename to x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go index 519de8b99e8..678513f5245 100644 --- a/x-pack/agent/pkg/agent/application/enroll_cmd_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/enroll_cmd_test.go @@ -19,9 +19,9 @@ import ( "github.com/pkg/errors" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/authority" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/authority" ) type mockStore struct { diff --git a/x-pack/agent/pkg/agent/application/error.go b/x-pack/elastic-agent/pkg/agent/application/error.go similarity index 100% rename from x-pack/agent/pkg/agent/application/error.go rename to x-pack/elastic-agent/pkg/agent/application/error.go diff --git a/x-pack/agent/pkg/agent/application/filters/constraints_filter.go b/x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter.go similarity index 94% rename from x-pack/agent/pkg/agent/application/filters/constraints_filter.go rename to x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter.go index 999d5bae998..9241f3dd3e6 100644 --- a/x-pack/agent/pkg/agent/application/filters/constraints_filter.go +++ b/x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter.go @@ -10,12 +10,12 @@ import ( "github.com/Masterminds/semver" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" "github.com/elastic/go-sysinfo" ) diff --git a/x-pack/agent/pkg/agent/application/filters/constraints_filter_test.go b/x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter_test.go similarity index 96% rename from x-pack/agent/pkg/agent/application/filters/constraints_filter_test.go rename to x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter_test.go index e5a05ccd265..d7a748d7fbd 100644 --- a/x-pack/agent/pkg/agent/application/filters/constraints_filter_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/filters/constraints_filter_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func TestEvaluation(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/application/fleet_acker.go b/x-pack/elastic-agent/pkg/agent/application/fleet_acker.go similarity index 85% rename from x-pack/agent/pkg/agent/application/fleet_acker.go rename to x-pack/elastic-agent/pkg/agent/application/fleet_acker.go index 46723462d3c..80529dec4af 100644 --- a/x-pack/agent/pkg/agent/application/fleet_acker.go +++ b/x-pack/elastic-agent/pkg/agent/application/fleet_acker.go @@ -9,10 +9,10 @@ import ( "fmt" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - "github.com/elastic/beats/v7/x-pack/agent/pkg/scheduler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler" ) const fleetTimeFormat = "2006-01-02T15:04:05.99999-07:00" @@ -51,7 +51,7 @@ func (f *actionAcker) Ack(ctx context.Context, action fleetapi.Action) error { _, err := cmd.Execute(ctx, req) if err != nil { - return errors.New(err, fmt.Sprintf("acknowledge action '%s' for agent '%s' failed", action.ID(), agentID), errors.TypeNetwork) + return errors.New(err, fmt.Sprintf("acknowledge action '%s' for elastic-agent '%s' failed", action.ID(), agentID), errors.TypeNetwork) } return nil @@ -72,7 +72,7 @@ func (f *actionAcker) AckBatch(ctx context.Context, actions []fleetapi.Action) e _, err := cmd.Execute(ctx, req) if err != nil { - return errors.New(err, fmt.Sprintf("acknowledge %d actions '%v' for agent '%s' failed", len(actions), actions, agentID), errors.TypeNetwork) + return errors.New(err, fmt.Sprintf("acknowledge %d actions '%v' for elastic-agent '%s' failed", len(actions), actions, agentID), errors.TypeNetwork) } return nil diff --git a/x-pack/agent/pkg/agent/application/fleet_acker_test.go b/x-pack/elastic-agent/pkg/agent/application/fleet_acker_test.go similarity index 91% rename from x-pack/agent/pkg/agent/application/fleet_acker_test.go rename to x-pack/elastic-agent/pkg/agent/application/fleet_acker_test.go index 6a9f3b7f09e..64d3f51f3e3 100644 --- a/x-pack/agent/pkg/agent/application/fleet_acker_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/fleet_acker_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) func TestAcker(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/application/fleet_gateway.go b/x-pack/elastic-agent/pkg/agent/application/fleet_gateway.go similarity index 94% rename from x-pack/agent/pkg/agent/application/fleet_gateway.go rename to x-pack/elastic-agent/pkg/agent/application/fleet_gateway.go index dd6b559972f..9092033bc5c 100644 --- a/x-pack/agent/pkg/agent/application/fleet_gateway.go +++ b/x-pack/elastic-agent/pkg/agent/application/fleet_gateway.go @@ -10,10 +10,10 @@ import ( "time" "github.com/elastic/beats/v7/libbeat/common/backoff" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - "github.com/elastic/beats/v7/x-pack/agent/pkg/scheduler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler" ) type dispatcher interface { diff --git a/x-pack/agent/pkg/agent/application/fleet_gateway_test.go b/x-pack/elastic-agent/pkg/agent/application/fleet_gateway_test.go similarity index 97% rename from x-pack/agent/pkg/agent/application/fleet_gateway_test.go rename to x-pack/elastic-agent/pkg/agent/application/fleet_gateway_test.go index d02264035ac..91cf687aa54 100644 --- a/x-pack/agent/pkg/agent/application/fleet_gateway_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/fleet_gateway_test.go @@ -20,10 +20,10 @@ import ( "github.com/pkg/errors" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - repo "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" - fleetreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/fleet" - "github.com/elastic/beats/v7/x-pack/agent/pkg/scheduler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + repo "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" + fleetreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/fleet" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler" ) type clientCallbackFunc func(headers http.Header, body io.Reader) (*http.Response, error) diff --git a/x-pack/agent/pkg/agent/application/global_config.go b/x-pack/elastic-agent/pkg/agent/application/global_config.go similarity index 91% rename from x-pack/agent/pkg/agent/application/global_config.go rename to x-pack/elastic-agent/pkg/agent/application/global_config.go index 8dd956d71c3..44e9f2772ff 100644 --- a/x-pack/agent/pkg/agent/application/global_config.go +++ b/x-pack/elastic-agent/pkg/agent/application/global_config.go @@ -8,8 +8,8 @@ import ( "os" "path/filepath" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" ) var ( diff --git a/x-pack/agent/pkg/agent/application/handler_action_policy_change.go b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go similarity index 79% rename from x-pack/agent/pkg/agent/application/handler_action_policy_change.go rename to x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go index c1793301542..996811260ef 100644 --- a/x-pack/agent/pkg/agent/application/handler_action_policy_change.go +++ b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change.go @@ -8,10 +8,10 @@ import ( "context" "fmt" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "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/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) type handlerConfigChange struct { diff --git a/x-pack/agent/pkg/agent/application/handler_action_policy_change_test.go b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change_test.go similarity index 94% rename from x-pack/agent/pkg/agent/application/handler_action_policy_change_test.go rename to x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change_test.go index a866ef1834f..400052f66f4 100644 --- a/x-pack/agent/pkg/agent/application/handler_action_policy_change_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/handler_action_policy_change_test.go @@ -13,9 +13,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) type mockEmitter struct { diff --git a/x-pack/agent/pkg/agent/application/handler_default.go b/x-pack/elastic-agent/pkg/agent/application/handler_default.go similarity index 87% rename from x-pack/agent/pkg/agent/application/handler_default.go rename to x-pack/elastic-agent/pkg/agent/application/handler_default.go index 885944520c6..8cbc1985d00 100644 --- a/x-pack/agent/pkg/agent/application/handler_default.go +++ b/x-pack/elastic-agent/pkg/agent/application/handler_default.go @@ -7,7 +7,7 @@ package application import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) type handlerDefault struct { diff --git a/x-pack/agent/pkg/agent/application/handler_unknown.go b/x-pack/elastic-agent/pkg/agent/application/handler_unknown.go similarity index 87% rename from x-pack/agent/pkg/agent/application/handler_unknown.go rename to x-pack/elastic-agent/pkg/agent/application/handler_unknown.go index dccbf8bd282..b263bf6be8d 100644 --- a/x-pack/agent/pkg/agent/application/handler_unknown.go +++ b/x-pack/elastic-agent/pkg/agent/application/handler_unknown.go @@ -7,7 +7,7 @@ package application import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) type handlerUnknown struct { diff --git a/x-pack/agent/pkg/agent/application/info/agent_id.go b/x-pack/elastic-agent/pkg/agent/application/info/agent_id.go similarity index 94% rename from x-pack/agent/pkg/agent/application/info/agent_id.go rename to x-pack/elastic-agent/pkg/agent/application/info/agent_id.go index 89b4494a5e4..c20f60972f9 100644 --- a/x-pack/agent/pkg/agent/application/info/agent_id.go +++ b/x-pack/elastic-agent/pkg/agent/application/info/agent_id.go @@ -12,9 +12,9 @@ import ( "github.com/gofrs/uuid" "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/storage" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/storage" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" ) // AgentConfigFile is a name of file used to store agent information diff --git a/x-pack/agent/pkg/agent/application/info/agent_info.go b/x-pack/elastic-agent/pkg/agent/application/info/agent_info.go similarity index 100% rename from x-pack/agent/pkg/agent/application/info/agent_info.go rename to x-pack/elastic-agent/pkg/agent/application/info/agent_info.go diff --git a/x-pack/agent/pkg/agent/application/lazy_acker.go b/x-pack/elastic-agent/pkg/agent/application/lazy_acker.go similarity index 94% rename from x-pack/agent/pkg/agent/application/lazy_acker.go rename to x-pack/elastic-agent/pkg/agent/application/lazy_acker.go index ea32dc6b869..58b212ab8e4 100644 --- a/x-pack/agent/pkg/agent/application/lazy_acker.go +++ b/x-pack/elastic-agent/pkg/agent/application/lazy_acker.go @@ -7,7 +7,7 @@ package application import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) type batchAcker interface { diff --git a/x-pack/agent/pkg/agent/application/lazy_acker_test.go b/x-pack/elastic-agent/pkg/agent/application/lazy_acker_test.go similarity index 95% rename from x-pack/agent/pkg/agent/application/lazy_acker_test.go rename to x-pack/elastic-agent/pkg/agent/application/lazy_acker_test.go index 358363a221d..cd941e64f83 100644 --- a/x-pack/agent/pkg/agent/application/lazy_acker_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/lazy_acker_test.go @@ -15,8 +15,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" ) func TestLazyAcker(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/application/local_meta.go b/x-pack/elastic-agent/pkg/agent/application/local_meta.go similarity index 89% rename from x-pack/agent/pkg/agent/application/local_meta.go rename to x-pack/elastic-agent/pkg/agent/application/local_meta.go index af3c6b4c977..47e358b6262 100644 --- a/x-pack/agent/pkg/agent/application/local_meta.go +++ b/x-pack/elastic-agent/pkg/agent/application/local_meta.go @@ -8,7 +8,7 @@ import ( "os" "runtime" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func metadata() (map[string]interface{}, error) { diff --git a/x-pack/agent/pkg/agent/application/local_mode.go b/x-pack/elastic-agent/pkg/agent/application/local_mode.go similarity index 83% rename from x-pack/agent/pkg/agent/application/local_mode.go rename to x-pack/elastic-agent/pkg/agent/application/local_mode.go index c7cac802a45..58a05bc86d0 100644 --- a/x-pack/agent/pkg/agent/application/local_mode.go +++ b/x-pack/elastic-agent/pkg/agent/application/local_mode.go @@ -7,15 +7,15 @@ package application import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/filters" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/dir" - reporting "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" - logreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/log" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/filters" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "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/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/dir" + reporting "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" + logreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/log" ) type emitterFunc func(*config.Config) error diff --git a/x-pack/agent/pkg/agent/application/managed_mode.go b/x-pack/elastic-agent/pkg/agent/application/managed_mode.go similarity index 83% rename from x-pack/agent/pkg/agent/application/managed_mode.go rename to x-pack/elastic-agent/pkg/agent/application/managed_mode.go index bcd64c11164..5e0ed718239 100644 --- a/x-pack/agent/pkg/agent/application/managed_mode.go +++ b/x-pack/elastic-agent/pkg/agent/application/managed_mode.go @@ -13,16 +13,16 @@ import ( "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/filters" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/info" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/storage" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - reporting "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" - fleetreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/fleet" - logreporter "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter/log" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/filters" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/info" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/storage" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + reporting "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" + fleetreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/fleet" + logreporter "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter/log" ) var gatewaySettings = &fleetGatewaySettings{ @@ -81,7 +81,7 @@ func newManaged( config, err := config.NewConfigFrom(reader) if err != nil { return nil, errors.New(err, - fmt.Sprintf("fail to read configuration %s for the agent", path), + fmt.Sprintf("fail to read configuration %s for the elastic-agent", path), errors.TypeFilesystem, errors.M(errors.MetaKeyPath, path)) } @@ -185,14 +185,14 @@ func newManaged( return managedApplication, nil } -// Start starts a managed agent. +// Start starts a managed elastic-agent. func (m *Managed) Start() error { m.log.Info("Agent is starting") m.gateway.Start() return nil } -// Stop stops a managed agent. +// Stop stops a managed elastic-agent. func (m *Managed) Stop() error { defer m.log.Info("Agent is stopped") m.gateway.Stop() @@ -200,7 +200,7 @@ func (m *Managed) Stop() error { return nil } -// AgentInfo retrieves agent information. +// AgentInfo retrieves elastic-agent information. func (m *Managed) AgentInfo() *info.AgentInfo { return m.agentInfo } diff --git a/x-pack/agent/pkg/agent/application/monitoring_decorator.go b/x-pack/elastic-agent/pkg/agent/application/monitoring_decorator.go similarity index 94% rename from x-pack/agent/pkg/agent/application/monitoring_decorator.go rename to x-pack/elastic-agent/pkg/agent/application/monitoring_decorator.go index 87a69538a50..b6925b56b31 100644 --- a/x-pack/agent/pkg/agent/application/monitoring_decorator.go +++ b/x-pack/elastic-agent/pkg/agent/application/monitoring_decorator.go @@ -7,8 +7,8 @@ package application import ( "fmt" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" ) const ( diff --git a/x-pack/agent/pkg/agent/application/monitoring_decorator_test.go b/x-pack/elastic-agent/pkg/agent/application/monitoring_decorator_test.go similarity index 96% rename from x-pack/agent/pkg/agent/application/monitoring_decorator_test.go rename to x-pack/elastic-agent/pkg/agent/application/monitoring_decorator_test.go index f8b3e4d4bf8..3d9b5265036 100644 --- a/x-pack/agent/pkg/agent/application/monitoring_decorator_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/monitoring_decorator_test.go @@ -7,8 +7,8 @@ package application import ( "testing" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" ) func TestMonitoringInjection(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/application/once.go b/x-pack/elastic-agent/pkg/agent/application/once.go similarity index 85% rename from x-pack/agent/pkg/agent/application/once.go rename to x-pack/elastic-agent/pkg/agent/application/once.go index f67e5d6611d..e4cb1d6dd90 100644 --- a/x-pack/agent/pkg/agent/application/once.go +++ b/x-pack/elastic-agent/pkg/agent/application/once.go @@ -5,8 +5,8 @@ package application import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) type once struct { diff --git a/x-pack/agent/pkg/agent/application/periodic.go b/x-pack/elastic-agent/pkg/agent/application/periodic.go similarity index 93% rename from x-pack/agent/pkg/agent/application/periodic.go rename to x-pack/elastic-agent/pkg/agent/application/periodic.go index c16407dbea6..1acf1a97377 100644 --- a/x-pack/agent/pkg/agent/application/periodic.go +++ b/x-pack/elastic-agent/pkg/agent/application/periodic.go @@ -8,9 +8,9 @@ import ( "strings" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/filewatcher" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/filewatcher" ) type periodic struct { diff --git a/x-pack/agent/pkg/agent/application/router.go b/x-pack/elastic-agent/pkg/agent/application/router.go similarity index 92% rename from x-pack/agent/pkg/agent/application/router.go rename to x-pack/elastic-agent/pkg/agent/application/router.go index 3d4a46f36d2..b48156d7d48 100644 --- a/x-pack/agent/pkg/agent/application/router.go +++ b/x-pack/elastic-agent/pkg/agent/application/router.go @@ -8,9 +8,9 @@ import ( "fmt" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/sorted" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/sorted" ) // defautlRK default routing keys until we implement the routing key / config matrix. diff --git a/x-pack/agent/pkg/agent/application/router_test.go b/x-pack/elastic-agent/pkg/agent/application/router_test.go similarity index 97% rename from x-pack/agent/pkg/agent/application/router_test.go rename to x-pack/elastic-agent/pkg/agent/application/router_test.go index 507629f053b..6edcd145eea 100644 --- a/x-pack/agent/pkg/agent/application/router_test.go +++ b/x-pack/elastic-agent/pkg/agent/application/router_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) type rOp int diff --git a/x-pack/agent/pkg/agent/application/stream.go b/x-pack/elastic-agent/pkg/agent/application/stream.go similarity index 79% rename from x-pack/agent/pkg/agent/application/stream.go rename to x-pack/elastic-agent/pkg/agent/application/stream.go index 43334735840..ab3e6426093 100644 --- a/x-pack/agent/pkg/agent/application/stream.go +++ b/x-pack/elastic-agent/pkg/agent/application/stream.go @@ -10,14 +10,14 @@ import ( "net/http" "net/url" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation" - operatorCfg "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/stateresolver" - downloader "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/localremote" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation" + operatorCfg "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/stateresolver" + downloader "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/localremote" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // EventProcessor is an processor of application event diff --git a/x-pack/agent/pkg/agent/cmd/cmd_test.go b/x-pack/elastic-agent/pkg/agent/cmd/cmd_test.go similarity index 93% rename from x-pack/agent/pkg/agent/cmd/cmd_test.go rename to x-pack/elastic-agent/pkg/agent/cmd/cmd_test.go index fb0ba3975a7..52ab81bc0b8 100644 --- a/x-pack/agent/pkg/agent/cmd/cmd_test.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/cmd_test.go @@ -19,7 +19,7 @@ func TestAgent(t *testing.T) { // t.Run("test run subcommand", func(t *testing.T) { // streams, _, out, _ := cli.NewTestingIOStreams() // cmd := newRunCommandWithArgs(globalFlags{ - // PathConfigFile: filepath.Join("build", "agent.yml"), + // PathConfigFile: filepath.Join("build", "elastic-agent.yml"), // }, []string{}, streams) // cmd.SetOutput(streams.Out) // cmd.Execute() diff --git a/x-pack/agent/pkg/agent/cmd/common.go b/x-pack/elastic-agent/pkg/agent/cmd/common.go similarity index 90% rename from x-pack/agent/pkg/agent/cmd/common.go rename to x-pack/elastic-agent/pkg/agent/cmd/common.go index 7c8019f3c61..0189f8e408d 100644 --- a/x-pack/agent/pkg/agent/cmd/common.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/common.go @@ -11,11 +11,11 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/x-pack/agent/pkg/basecmd" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/basecmd" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" ) -var defaultConfig = "agent.yml" +var defaultConfig = "elastic-agent.yml" type globalFlags struct { PathConfigFile string @@ -45,7 +45,7 @@ func NewCommand() *cobra.Command { // NewCommandWithArgs returns a new agent with the flags and the subcommand. func NewCommandWithArgs(args []string, streams *cli.IOStreams) *cobra.Command { cmd := &cobra.Command{ - Use: "agent [subcommand]", + Use: "elastic-agent [subcommand]", } flags := &globalFlags{} diff --git a/x-pack/agent/pkg/agent/cmd/enroll.go b/x-pack/elastic-agent/pkg/agent/cmd/enroll.go similarity index 88% rename from x-pack/agent/pkg/agent/cmd/enroll.go rename to x-pack/elastic-agent/pkg/agent/cmd/enroll.go index d61804e9ba7..a2a7ee48d22 100644 --- a/x-pack/agent/pkg/agent/cmd/enroll.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/enroll.go @@ -13,12 +13,12 @@ import ( "github.com/spf13/cobra" c "github.com/elastic/beats/v7/libbeat/common/cli" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/warn" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/warn" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) var defaultDelay = 1 * time.Second diff --git a/x-pack/agent/pkg/agent/cmd/run.go b/x-pack/elastic-agent/pkg/agent/cmd/run.go similarity index 78% rename from x-pack/agent/pkg/agent/cmd/run.go rename to x-pack/elastic-agent/pkg/agent/cmd/run.go index 9bddb41f2e6..f0196ba7875 100644 --- a/x-pack/agent/pkg/agent/cmd/run.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/run.go @@ -12,17 +12,17 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func newRunCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStreams) *cobra.Command { return &cobra.Command{ Use: "run", - Short: "Start the agent.", + Short: "Start the elastic-agent.", Run: func(_ *cobra.Command, _ []string) { if err := run(flags, streams); err != nil { fmt.Fprintf(streams.Err, "%v\n", err) diff --git a/x-pack/agent/pkg/agent/configrequest/request.go b/x-pack/elastic-agent/pkg/agent/configrequest/request.go similarity index 86% rename from x-pack/agent/pkg/agent/configrequest/request.go rename to x-pack/elastic-agent/pkg/agent/configrequest/request.go index 2c29513ed76..b3cb3063ecc 100644 --- a/x-pack/agent/pkg/agent/configrequest/request.go +++ b/x-pack/elastic-agent/pkg/agent/configrequest/request.go @@ -7,7 +7,7 @@ package configrequest import ( "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" ) // Request is the minimal interface a config request must have. diff --git a/x-pack/agent/pkg/agent/configrequest/step.go b/x-pack/elastic-agent/pkg/agent/configrequest/step.go similarity index 100% rename from x-pack/agent/pkg/agent/configrequest/step.go rename to x-pack/elastic-agent/pkg/agent/configrequest/step.go diff --git a/x-pack/agent/pkg/agent/errors/error.go b/x-pack/elastic-agent/pkg/agent/errors/error.go similarity index 100% rename from x-pack/agent/pkg/agent/errors/error.go rename to x-pack/elastic-agent/pkg/agent/errors/error.go diff --git a/x-pack/agent/pkg/agent/errors/error_test.go b/x-pack/elastic-agent/pkg/agent/errors/error_test.go similarity index 100% rename from x-pack/agent/pkg/agent/errors/error_test.go rename to x-pack/elastic-agent/pkg/agent/errors/error_test.go diff --git a/x-pack/agent/pkg/agent/errors/generators.go b/x-pack/elastic-agent/pkg/agent/errors/generators.go similarity index 100% rename from x-pack/agent/pkg/agent/errors/generators.go rename to x-pack/elastic-agent/pkg/agent/errors/generators.go diff --git a/x-pack/agent/pkg/agent/errors/types.go b/x-pack/elastic-agent/pkg/agent/errors/types.go similarity index 100% rename from x-pack/agent/pkg/agent/errors/types.go rename to x-pack/elastic-agent/pkg/agent/errors/types.go diff --git a/x-pack/agent/pkg/agent/internal/yamltest/yaml.go b/x-pack/elastic-agent/pkg/agent/internal/yamltest/yaml.go similarity index 100% rename from x-pack/agent/pkg/agent/internal/yamltest/yaml.go rename to x-pack/elastic-agent/pkg/agent/internal/yamltest/yaml.go diff --git a/x-pack/agent/pkg/agent/operation/common_test.go b/x-pack/elastic-agent/pkg/agent/operation/common_test.go similarity index 71% rename from x-pack/agent/pkg/agent/operation/common_test.go rename to x-pack/elastic-agent/pkg/agent/operation/common_test.go index 3985f296173..a50b4dfc7a0 100644 --- a/x-pack/agent/pkg/agent/operation/common_test.go +++ b/x-pack/elastic-agent/pkg/agent/operation/common_test.go @@ -9,17 +9,17 @@ import ( "testing" "time" - operatorCfg "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/stateresolver" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" + operatorCfg "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/stateresolver" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" ) var installPath = "tests/scripts" diff --git a/x-pack/agent/pkg/agent/operation/config/config.go b/x-pack/elastic-agent/pkg/agent/operation/config/config.go similarity index 67% rename from x-pack/agent/pkg/agent/operation/config/config.go rename to x-pack/elastic-agent/pkg/agent/operation/config/config.go index 35ff517f8bf..74a4212e83c 100644 --- a/x-pack/agent/pkg/agent/operation/config/config.go +++ b/x-pack/elastic-agent/pkg/agent/operation/config/config.go @@ -5,10 +5,10 @@ package config import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" ) // Config is an operator configuration diff --git a/x-pack/agent/pkg/agent/operation/event_processor.go b/x-pack/elastic-agent/pkg/agent/operation/event_processor.go similarity index 100% rename from x-pack/agent/pkg/agent/operation/event_processor.go rename to x-pack/elastic-agent/pkg/agent/operation/event_processor.go diff --git a/x-pack/agent/pkg/agent/operation/monitoring.go b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go similarity index 95% rename from x-pack/agent/pkg/agent/operation/monitoring.go rename to x-pack/elastic-agent/pkg/agent/operation/monitoring.go index c00eb605731..8157bf9e876 100644 --- a/x-pack/agent/pkg/agent/operation/monitoring.go +++ b/x-pack/elastic-agent/pkg/agent/operation/monitoring.go @@ -7,11 +7,11 @@ package operation import ( "github.com/hashicorp/go-multierror" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" ) const ( diff --git a/x-pack/agent/pkg/agent/operation/monitoring_test.go b/x-pack/elastic-agent/pkg/agent/operation/monitoring_test.go similarity index 85% rename from x-pack/agent/pkg/agent/operation/monitoring_test.go rename to x-pack/elastic-agent/pkg/agent/operation/monitoring_test.go index 4b2ae2b444e..4ae08d4001c 100644 --- a/x-pack/agent/pkg/agent/operation/monitoring_test.go +++ b/x-pack/elastic-agent/pkg/agent/operation/monitoring_test.go @@ -9,16 +9,16 @@ import ( "testing" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - operatorCfg "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/stateresolver" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring/beats" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + operatorCfg "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/stateresolver" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" ) func TestGenerateSteps(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/operation/operation.go b/x-pack/elastic-agent/pkg/agent/operation/operation.go similarity index 90% rename from x-pack/agent/pkg/agent/operation/operation.go rename to x-pack/elastic-agent/pkg/agent/operation/operation.go index b18fab74db1..00545d3b34e 100644 --- a/x-pack/agent/pkg/agent/operation/operation.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation.go @@ -7,8 +7,8 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" ) // operation is an operation definition diff --git a/x-pack/agent/pkg/agent/operation/operation_config.go b/x-pack/elastic-agent/pkg/agent/operation/operation_config.go similarity index 89% rename from x-pack/agent/pkg/agent/operation/operation_config.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_config.go index 92722eba0dc..b50aef4de7a 100644 --- a/x-pack/agent/pkg/agent/operation/operation_config.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_config.go @@ -7,9 +7,9 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) var ( diff --git a/x-pack/agent/pkg/agent/operation/operation_fetch.go b/x-pack/elastic-agent/pkg/agent/operation/operation_fetch.go similarity index 87% rename from x-pack/agent/pkg/agent/operation/operation_fetch.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_fetch.go index df1556544f2..3c25287e1c7 100644 --- a/x-pack/agent/pkg/agent/operation/operation_fetch.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_fetch.go @@ -8,11 +8,11 @@ import ( "context" "os" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // operationFetch fetches artifact from preconfigured source diff --git a/x-pack/agent/pkg/agent/operation/operation_install.go b/x-pack/elastic-agent/pkg/agent/operation/operation_install.go similarity index 86% rename from x-pack/agent/pkg/agent/operation/operation_install.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_install.go index 6f1ac2b12e4..34faf9a7fc2 100644 --- a/x-pack/agent/pkg/agent/operation/operation_install.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_install.go @@ -8,10 +8,10 @@ import ( "context" "os" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // operationInstall installs a artifact from predefined location diff --git a/x-pack/agent/pkg/agent/operation/operation_remove.go b/x-pack/elastic-agent/pkg/agent/operation/operation_remove.go similarity index 94% rename from x-pack/agent/pkg/agent/operation/operation_remove.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_remove.go index 4d93d585095..fb3370ba156 100644 --- a/x-pack/agent/pkg/agent/operation/operation_remove.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_remove.go @@ -7,7 +7,7 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // operationRemove uninstall and removes all the bits related to the artifact diff --git a/x-pack/agent/pkg/agent/operation/operation_start.go b/x-pack/elastic-agent/pkg/agent/operation/operation_start.go similarity index 83% rename from x-pack/agent/pkg/agent/operation/operation_start.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_start.go index f09c5dc85e3..5b10ef8b248 100644 --- a/x-pack/agent/pkg/agent/operation/operation_start.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_start.go @@ -7,11 +7,11 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" ) // operationStart start installed process diff --git a/x-pack/agent/pkg/agent/operation/operation_stop.go b/x-pack/elastic-agent/pkg/agent/operation/operation_stop.go similarity index 88% rename from x-pack/agent/pkg/agent/operation/operation_stop.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_stop.go index de7809612c0..b6206fd0d54 100644 --- a/x-pack/agent/pkg/agent/operation/operation_stop.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_stop.go @@ -7,9 +7,9 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // operationStop stops the running process diff --git a/x-pack/agent/pkg/agent/operation/operation_verify.go b/x-pack/elastic-agent/pkg/agent/operation/operation_verify.go similarity index 95% rename from x-pack/agent/pkg/agent/operation/operation_verify.go rename to x-pack/elastic-agent/pkg/agent/operation/operation_verify.go index b2ab818eb7d..b0957ef2060 100644 --- a/x-pack/agent/pkg/agent/operation/operation_verify.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operation_verify.go @@ -7,7 +7,7 @@ package operation import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // operationVerify verifies downloaded artifact for correct signature diff --git a/x-pack/agent/pkg/agent/operation/operator.go b/x-pack/elastic-agent/pkg/agent/operation/operator.go similarity index 87% rename from x-pack/agent/pkg/agent/operation/operator.go rename to x-pack/elastic-agent/pkg/agent/operation/operator.go index 9eee74af1cf..6aed0d802f3 100644 --- a/x-pack/agent/pkg/agent/operation/operator.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator.go @@ -12,20 +12,20 @@ import ( "sync" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - operatorCfg "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/stateresolver" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" - rconfig "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig/grpc" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + operatorCfg "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/stateresolver" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" + rconfig "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" ) // Operator runs Start/Stop/Update operations diff --git a/x-pack/agent/pkg/agent/operation/operator_handlers.go b/x-pack/elastic-agent/pkg/agent/operation/operator_handlers.go similarity index 88% rename from x-pack/agent/pkg/agent/operation/operator_handlers.go rename to x-pack/elastic-agent/pkg/agent/operation/operator_handlers.go index 34022763bcb..3e7d796f7a3 100644 --- a/x-pack/agent/pkg/agent/operation/operator_handlers.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator_handlers.go @@ -7,11 +7,11 @@ package operation import ( "fmt" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) type handleFunc func(step configrequest.Step) error diff --git a/x-pack/agent/pkg/agent/operation/operator_test.go b/x-pack/elastic-agent/pkg/agent/operation/operator_test.go similarity index 97% rename from x-pack/agent/pkg/agent/operation/operator_test.go rename to x-pack/elastic-agent/pkg/agent/operation/operator_test.go index 07e24f69ef3..ea763f7e875 100644 --- a/x-pack/agent/pkg/agent/operation/operator_test.go +++ b/x-pack/elastic-agent/pkg/agent/operation/operator_test.go @@ -14,10 +14,10 @@ import ( "testing" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" ) func TestMain(m *testing.M) { diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/README.md b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/README.md similarity index 100% rename from x-pack/agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/README.md rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/README.md diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go similarity index 90% rename from x-pack/agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go index 78bfeaf2f9d..0ca3be9192f 100644 --- a/x-pack/agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go +++ b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurable-1.0-darwin-x86/main.go @@ -11,8 +11,8 @@ import ( "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/server" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig/grpc" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/server" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" ) func main() { diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/README.md b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/README.md similarity index 100% rename from x-pack/agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/README.md rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/README.md diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/main.go b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/main.go similarity index 100% rename from x-pack/agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/main.go rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/configurablebyfile-1.0-darwin-x86/main.go diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/long-1.0-darwin-x86/README.md b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/long-1.0-darwin-x86/README.md similarity index 100% rename from x-pack/agent/pkg/agent/operation/tests/scripts/long-1.0-darwin-x86/README.md rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/long-1.0-darwin-x86/README.md diff --git a/x-pack/agent/pkg/agent/operation/tests/scripts/short-1.0-darwin-x86/README.md b/x-pack/elastic-agent/pkg/agent/operation/tests/scripts/short-1.0-darwin-x86/README.md similarity index 100% rename from x-pack/agent/pkg/agent/operation/tests/scripts/short-1.0-darwin-x86/README.md rename to x-pack/elastic-agent/pkg/agent/operation/tests/scripts/short-1.0-darwin-x86/README.md diff --git a/x-pack/agent/pkg/agent/program/methods.go b/x-pack/elastic-agent/pkg/agent/program/methods.go similarity index 96% rename from x-pack/agent/pkg/agent/program/methods.go rename to x-pack/elastic-agent/pkg/agent/program/methods.go index ce774144d86..c47fca5928f 100644 --- a/x-pack/agent/pkg/agent/program/methods.go +++ b/x-pack/elastic-agent/pkg/agent/program/methods.go @@ -7,8 +7,8 @@ package program import ( "fmt" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp" ) type env struct { diff --git a/x-pack/agent/pkg/agent/program/program.go b/x-pack/elastic-agent/pkg/agent/program/program.go similarity index 96% rename from x-pack/agent/pkg/agent/program/program.go rename to x-pack/elastic-agent/pkg/agent/program/program.go index 344a54e743a..f9fd50983d7 100644 --- a/x-pack/agent/pkg/agent/program/program.go +++ b/x-pack/elastic-agent/pkg/agent/program/program.go @@ -8,9 +8,9 @@ import ( "fmt" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp" ) // Program represents a program that must be started or must run. @@ -102,7 +102,7 @@ func detectPrograms(singleConfig *transpiler.AST) ([]Program, error) { } -// KnownProgramNames returns a list of runnable programs by the agent. +// KnownProgramNames returns a list of runnable programs by the elastic-agent. func KnownProgramNames() []string { names := make([]string, len(Supported)) for idx, program := range Supported { diff --git a/x-pack/agent/pkg/agent/program/program_test.go b/x-pack/elastic-agent/pkg/agent/program/program_test.go similarity index 97% rename from x-pack/agent/pkg/agent/program/program_test.go rename to x-pack/elastic-agent/pkg/agent/program/program_test.go index af5e61751bb..85d471c6583 100644 --- a/x-pack/agent/pkg/agent/program/program_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/program_test.go @@ -16,10 +16,10 @@ import ( "github.com/stretchr/testify/require" yaml "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/application/filters" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/internal/yamltest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/application/filters" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/internal/yamltest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func TestGroupBy(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/program/spec.go b/x-pack/elastic-agent/pkg/agent/program/spec.go similarity index 94% rename from x-pack/agent/pkg/agent/program/spec.go rename to x-pack/elastic-agent/pkg/agent/program/spec.go index c9cfe9a7d0b..492b6a58ce5 100644 --- a/x-pack/agent/pkg/agent/program/spec.go +++ b/x-pack/elastic-agent/pkg/agent/program/spec.go @@ -13,8 +13,8 @@ import ( "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" ) // ErrMissingWhen is returned when no boolean expression is defined for a program. diff --git a/x-pack/agent/pkg/agent/program/spec_test.go b/x-pack/elastic-agent/pkg/agent/program/spec_test.go similarity index 97% rename from x-pack/agent/pkg/agent/program/spec_test.go rename to x-pack/elastic-agent/pkg/agent/program/spec_test.go index fd3db0374b2..cc95b627fa2 100644 --- a/x-pack/agent/pkg/agent/program/spec_test.go +++ b/x-pack/elastic-agent/pkg/agent/program/spec_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" ) func TestSerialization(t *testing.T) { diff --git a/x-pack/elastic-agent/pkg/agent/program/supported.go b/x-pack/elastic-agent/pkg/agent/program/supported.go new file mode 100644 index 00000000000..4044105b6cc --- /dev/null +++ b/x-pack/elastic-agent/pkg/agent/program/supported.go @@ -0,0 +1,33 @@ +// 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. + +// Code generated by x-pack/dev-tools/cmd/buildspec/buildspec.go - DO NOT EDIT. + +package program + +import ( + "strings" + + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/packer" +) + +var Supported []Spec +var SupportedMap map[string]bool + +func init() { + // Packed Files + // spec/filebeat.yml + // spec/metricbeat.yml + unpacked := packer.MustUnpack("eJzsV02To7oV3edn9DapBES7E1I1C0M/BNhNj3E3EtpZkhuwJUw1+ANS+e8pCRsb98xLTb3tW0x5GqT7ce6951z+81BXa/aPj0Ks6XrV/L2V4uHfD1R6DXnbZbEUNUGhSPFilgJz+1o4coVOIpVJzqdVziTvXguHBoXpBcUxC8pIcD85zqWo6XIiqPQKCpPtd0Ry6kdCn7k/W8aCYqdOcSzmMtmnKKwJWthEejUD78XcnRbz9/6XIm+fIi4oSvbcnTQUxOI7zhoGvc2qNSWFieBuUAdu0MRL9Rs2KZrkBCQNQRPj1j73Q5MsQ+7K6EAlqYiVtPrd2y4jVnhMj1XL0UmwbjebL52KykqkVvyxQpMtwdmTW0yzwHWMNXbEa+HUFPDOzXZNAJNH7oe5Okuh6LhnVxwmjbITuNMs8J2cw+wpgHHOoddR5Rck3dmePvtaOBUtHZP7L+c78eH6LOq4H4oUmWd/Zs6e722LPfMTg1mRwWSSU3yxE5oUJt1rtsvU3/Ols6GWM8HAq6lnG9S06xWOjMv7G99Xn8V0eEctIljJ2xWOFQYyRaeOLG7uwuQxBcmRP+8y1IaDDV1/Kbb971ATXWMOhUFhX29dV+CVpK/lPkWmYJaTp+e+SIG9Z1bcpkjsuf/S38eRwMA2ue+Y3A35r9XkJ7hBYRBkPAX+PZ63dXmZuYWRUeQdL/gx6Bmr5122QpMjx/GlxkNf9TgZmYqNlpGegTH257j8eMLg+2x47jpNip0jwcHTbT0Ct+/Dvh/ZzXldC6BnAJCKwvenAJ4O5Hjjy51mBBNBy8WBWfF2hR51vgSK/Z0PwaWaP9tIramKbcOmP7bDUXx8LRyT+NO7WE4H0tpbCqJPlUMA40MKGsGysR0K7XJuhYJA0WErqqnFVV5Pgd8/+5o7OzBLdOqe6tk1jjQOfQ+QivqxYMIGKTqZBL9cZrgjitOs+MA2X2r1SfB2jL+vuCwZ1U/5O8fS3GHWBH6yveAzXzoKs+EegfZmBZL2enaUl7I1YUDXSXGQ4l6D4PCDS6/m6DrHDCQ1QZFBreDaw+farkAyeS2cgYvPed1hoHzFLUfvuodTYB/Xb+f8IGkpML7Y5fBfTxpTmBQEecYI481lriJBYbLh0G5v8SI3ujJgaCWGsj/EAxuxxiqnULgl3xHVj7/lOTPULJrdzE3+icDV/1ye4zNNe7acyrBwghRHrzecsQsHXmB14HJBoddxKDYMJDmT0S5sj1l47rewParYyhXw5Ar8Vs7daanqzKw4ZyArZ4vdt4e/9fIp181nwX4goG8oMZgUm7NgbihaPAXQFNwPqxSchRWHJesUQQ6i1REcm8ydVBQae4ImeSpPgjybPcEuRwJ3OatAOVLoGeT/Ca80cyq9kiBTDemeIntL3szHOVYg1Q1RvvDi94T3ah/rpinwotpQMJErxE2m3ymC4S2DLzMGbU24tIyMFJ3qvmkVUdqAJLZeKK6k5xxTHO9eC+XT3mqibCfbuRVNmBULupxMKDoWw+D7sVpChBKYQJoH4ic1wS974tpq+BVp79fIrOcyrhjoYw6yXxL2huC4XaHoT3H/g+KOFxpvsfaVYEcGBqeKKdyxWgAHMj7X/wd4jDG8f27Q7oa8sx8TJrZ4xWH+wWRSEpwPQn0mSV3zi0ir+cXF4+ccnOfVetn+rmD8UZGBA1Y/FRq9tPY4Nime/gSzn/aDwaS3Z+CUc5h8cCCMlWe3BHGx9qejReKyuHBfHEc190PVC+vZs7343oviX+dFXX3FqP+nfTzvsnC0wBgZ031hjpedi9B8XXZ0bS98cBUIM1+B5CPFYZvi7Sh+3VNv6k7PvwwMwnIjXpeY1YfIy21sjep9DBoxiKB7W6ebe1dhbwkyD1wmH7qXRnlpO9nA479yB3pGirWf2WWeL+dIGR5Ujne9dMbqVnf03Vb5p+j90jOSSbu54bexiI5EfuBVvRwo8eYwab8uH+Ftr43sXmt2FuArBp8Ei04tCKqvOcgF3eyyJfS6Zc8LuxA3dJRP/+GnextjowrcVPaLgcov6dRHA1lm5WWh0KIOkjrFkaF4nCCvTUFWznUMvCUorlirF4LPFJHPdKn/rxdpxeErl1Vu9u3bw3//8r8AAAD//7NUG+I=") + SupportedMap = make(map[string]bool) + + for f, v := range unpacked { + s, err := NewSpecFromBytes(v) + if err != nil { + panic("Cannot read spec from " + f) + } + Supported = append(Supported, s) + SupportedMap[strings.ToLower(s.Name)] = true + } +} diff --git a/x-pack/agent/pkg/agent/program/testdata/audit_config-auditbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/audit_config-auditbeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/audit_config-auditbeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/audit_config-auditbeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/audit_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/audit_config.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/audit_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/audit_config.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/constraints_config-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/constraints_config-filebeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/constraints_config-filebeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/constraints_config-filebeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/constraints_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/constraints_config.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/constraints_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/constraints_config.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_false.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_false.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_false.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_false.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_output_false.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_false.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_output_false.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_false.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true-filebeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_output_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_output_true.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_output_true.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_true-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_true-filebeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true-filebeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/enabled_true.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/enabled_true.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/enabled_true.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/journal_config-journalbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/journal_config-journalbeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/journal_config-journalbeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/journal_config-journalbeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/journal_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/journal_config.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/journal_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/journal_config.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config-heartbeat.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/monitor_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml similarity index 100% rename from x-pack/agent/pkg/agent/program/testdata/monitor_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/monitor_config.yml diff --git a/x-pack/agent/pkg/agent/program/testdata/single_config-filebeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml similarity index 93% rename from x-pack/agent/pkg/agent/program/testdata/single_config-filebeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml index c61497d3404..dd26c83681a 100644 --- a/x-pack/agent/pkg/agent/program/testdata/single_config-filebeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-filebeat.yml @@ -5,6 +5,8 @@ filebeat: - /var/log/hello1.log - /var/log/hello2.log index: logs-generic-default + vars: + var: value output: elasticsearch: hosts: diff --git a/x-pack/agent/pkg/agent/program/testdata/single_config-metricbeat.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml similarity index 85% rename from x-pack/agent/pkg/agent/program/testdata/single_config-metricbeat.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml index e4508d88a39..7fc9f33e6b0 100644 --- a/x-pack/agent/pkg/agent/program/testdata/single_config-metricbeat.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config-metricbeat.yml @@ -3,9 +3,11 @@ metricbeat: - module: docker metricsets: [status] index: metrics-docker.status-default + hosts: ["http://127.0.0.1:8080"] - module: apache metricsets: [info] index: metrics-generic-testing + hosts: ["http://apache.remote"] output: elasticsearch: hosts: [127.0.0.1:9200, 127.0.0.1:9300] diff --git a/x-pack/agent/pkg/agent/program/testdata/single_config.yml b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml similarity index 86% rename from x-pack/agent/pkg/agent/program/testdata/single_config.yml rename to x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml index ad228c30591..b986a7b686b 100644 --- a/x-pack/agent/pkg/agent/program/testdata/single_config.yml +++ b/x-pack/elastic-agent/pkg/agent/program/testdata/single_config.yml @@ -26,11 +26,14 @@ datasources: streams: - metricset: status dataset: docker.status + hosts: ["http://127.0.0.1:8080"] - type: logs streams: - paths: - /var/log/hello1.log - /var/log/hello2.log + vars: + var: value - namespace: testing use_output: default inputs: @@ -38,6 +41,9 @@ datasources: streams: - enabled: true metricset: info + hosts: ["http://apache.remote"] + hosts: ["http://apache.local"] + id: apache-metrics-id settings.monitoring: use_output: monitoring diff --git a/x-pack/agent/pkg/agent/stateresolver/resolve.go b/x-pack/elastic-agent/pkg/agent/stateresolver/resolve.go similarity index 95% rename from x-pack/agent/pkg/agent/stateresolver/resolve.go rename to x-pack/elastic-agent/pkg/agent/stateresolver/resolve.go index d9781bbd6d3..b4d194c40b1 100644 --- a/x-pack/agent/pkg/agent/stateresolver/resolve.go +++ b/x-pack/elastic-agent/pkg/agent/stateresolver/resolve.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) //go:generate stringer -type=stateChange -linecomment=true diff --git a/x-pack/agent/pkg/agent/stateresolver/resolve_test.go b/x-pack/elastic-agent/pkg/agent/stateresolver/resolve_test.go similarity index 96% rename from x-pack/agent/pkg/agent/stateresolver/resolve_test.go rename to x-pack/elastic-agent/pkg/agent/stateresolver/resolve_test.go index 5ae81e80f1d..1d576833e30 100644 --- a/x-pack/agent/pkg/agent/stateresolver/resolve_test.go +++ b/x-pack/elastic-agent/pkg/agent/stateresolver/resolve_test.go @@ -11,10 +11,10 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/transpiler" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/transpiler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func TestResolver(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/stateresolver/statechange_string.go b/x-pack/elastic-agent/pkg/agent/stateresolver/statechange_string.go similarity index 100% rename from x-pack/agent/pkg/agent/stateresolver/statechange_string.go rename to x-pack/elastic-agent/pkg/agent/stateresolver/statechange_string.go diff --git a/x-pack/agent/pkg/agent/stateresolver/stateresolver.go b/x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver.go similarity index 88% rename from x-pack/agent/pkg/agent/stateresolver/stateresolver.go rename to x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver.go index bcc686b8380..e5b2d82e287 100644 --- a/x-pack/agent/pkg/agent/stateresolver/stateresolver.go +++ b/x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver.go @@ -7,9 +7,9 @@ package stateresolver import ( "sync" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/configrequest" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - uid "github.com/elastic/beats/v7/x-pack/agent/pkg/id" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/configrequest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + uid "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/id" ) // Acker allow to ack the should state from a converge operation. diff --git a/x-pack/agent/pkg/agent/stateresolver/stateresolver_test.go b/x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver_test.go similarity index 91% rename from x-pack/agent/pkg/agent/stateresolver/stateresolver_test.go rename to x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver_test.go index 629e477f85e..df6335f0668 100644 --- a/x-pack/agent/pkg/agent/stateresolver/stateresolver_test.go +++ b/x-pack/elastic-agent/pkg/agent/stateresolver/stateresolver_test.go @@ -11,8 +11,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func TestStateResolverAcking(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/storage/storage.go b/x-pack/elastic-agent/pkg/agent/storage/storage.go similarity index 98% rename from x-pack/agent/pkg/agent/storage/storage.go rename to x-pack/elastic-agent/pkg/agent/storage/storage.go index 1e910b4ddec..d2a6505ba7e 100644 --- a/x-pack/agent/pkg/agent/storage/storage.go +++ b/x-pack/elastic-agent/pkg/agent/storage/storage.go @@ -13,8 +13,8 @@ import ( "time" "github.com/elastic/beats/v7/libbeat/common/file" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/crypto" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/crypto" ) const perms = 0600 diff --git a/x-pack/agent/pkg/agent/storage/storage_test.go b/x-pack/elastic-agent/pkg/agent/storage/storage_test.go similarity index 100% rename from x-pack/agent/pkg/agent/storage/storage_test.go rename to x-pack/elastic-agent/pkg/agent/storage/storage_test.go diff --git a/x-pack/agent/pkg/agent/transpiler/ast.go b/x-pack/elastic-agent/pkg/agent/transpiler/ast.go similarity index 100% rename from x-pack/agent/pkg/agent/transpiler/ast.go rename to x-pack/elastic-agent/pkg/agent/transpiler/ast.go diff --git a/x-pack/agent/pkg/agent/transpiler/ast_test.go b/x-pack/elastic-agent/pkg/agent/transpiler/ast_test.go similarity index 100% rename from x-pack/agent/pkg/agent/transpiler/ast_test.go rename to x-pack/elastic-agent/pkg/agent/transpiler/ast_test.go diff --git a/x-pack/agent/pkg/agent/transpiler/map_visitor.go b/x-pack/elastic-agent/pkg/agent/transpiler/map_visitor.go similarity index 100% rename from x-pack/agent/pkg/agent/transpiler/map_visitor.go rename to x-pack/elastic-agent/pkg/agent/transpiler/map_visitor.go diff --git a/x-pack/agent/pkg/agent/transpiler/rules.go b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go similarity index 93% rename from x-pack/agent/pkg/agent/transpiler/rules.go rename to x-pack/elastic-agent/pkg/agent/transpiler/rules.go index 96f16d18b6d..50eddecf3ab 100644 --- a/x-pack/agent/pkg/agent/transpiler/rules.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/rules.go @@ -11,7 +11,7 @@ import ( "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // RuleList is a container that allow the same tree to be executed on multiple defined Rule. @@ -49,6 +49,8 @@ func (r *RuleList) MarshalYAML() (interface{}, error) { name = "copy" case *CopyToListRule: name = "copy_to_list" + case *CopyAllToListRule: + name = "copy_all_to_list" case *RenameRule: name = "rename" case *TranslateRule: @@ -123,6 +125,8 @@ func (r *RuleList) UnmarshalYAML(unmarshal func(interface{}) error) error { r = &CopyRule{} case "copy_to_list": r = &CopyToListRule{} + case "copy_all_to_list": + r = &CopyAllToListRule{} case "rename": r = &RenameRule{} case "translate": @@ -231,8 +235,9 @@ func MakeArray(item Selector, to string) *MakeArrayRule { // CopyToListRule is a rule which copies a specified // node into every item in a provided list. type CopyToListRule struct { - Item Selector - To string + Item Selector + To string + Overwrite bool } // Apply copies specified node into every item of the list. @@ -260,6 +265,13 @@ func (r *CopyToListRule) Apply(ast *AST) error { continue } + if !r.Overwrite { + _, found := listItemMap.Find(r.Item) + if found { + continue + } + } + listItemMap.value = append(listItemMap.value, sourceNode.Clone()) } @@ -267,10 +279,60 @@ func (r *CopyToListRule) Apply(ast *AST) error { } // CopyToList creates a CopyToListRule -func CopyToList(item Selector, to string) *CopyToListRule { +func CopyToList(item Selector, to string, overwrite bool) *CopyToListRule { return &CopyToListRule{ - Item: item, - To: to, + Item: item, + To: to, + Overwrite: overwrite, + } +} + +// CopyAllToListRule is a rule which copies a all nodes +// into every item in a provided list. +type CopyAllToListRule struct { + To string + Except []string + Overwrite bool +} + +// Apply copies all nodes into every item of the list. +func (r *CopyAllToListRule) Apply(ast *AST) error { + // get list of nodes + astMap, err := ast.Map() + if err != nil { + return err + } + + isFiltered := func(item string) bool { + for _, f := range r.Except { + if f == item { + return true + } + } + + return false + } + + // foreach node if not filtered out + for item := range astMap { + if isFiltered(item) { + continue + } + + if err := CopyToList(item, r.To, r.Overwrite).Apply(ast); err != nil { + return err + } + } + + return nil +} + +// CopyAllToList creates a CopyAllToListRule +func CopyAllToList(to string, overwrite bool, except ...string) *CopyAllToListRule { + return &CopyAllToListRule{ + To: to, + Except: except, + Overwrite: overwrite, } } diff --git a/x-pack/agent/pkg/agent/transpiler/rules_test.go b/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go similarity index 97% rename from x-pack/agent/pkg/agent/transpiler/rules_test.go rename to x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go index 703172343b5..36463cfabc0 100644 --- a/x-pack/agent/pkg/agent/transpiler/rules_test.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/rules_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/internal/yamltest" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/internal/yamltest" ) func TestRules(t *testing.T) { @@ -481,7 +481,7 @@ inputs: `, rule: &RuleList{ Rules: []Rule{ - CopyToList("namespace", "inputs"), + CopyToList("namespace", "inputs", false), }, }, }, @@ -561,7 +561,8 @@ func TestSerialization(t *testing.T) { FilterValuesWithRegexp("inputs", "type", regexp.MustCompile("^metric/.*")), ExtractListItem("path.p", "item", "target"), InjectIndex("index-type"), - CopyToList("t1", "t2"), + CopyToList("t1", "t2", false), + CopyAllToList("t2", false, "a", "b"), ) y := `- rename: @@ -611,6 +612,13 @@ func TestSerialization(t *testing.T) { - copy_to_list: item: t1 to: t2 + overwrite: false +- copy_all_to_list: + to: t2 + except: + - a + - b + overwrite: false ` t.Run("serialize_rules", func(t *testing.T) { diff --git a/x-pack/agent/pkg/agent/transpiler/steps.go b/x-pack/elastic-agent/pkg/agent/transpiler/steps.go similarity index 85% rename from x-pack/agent/pkg/agent/transpiler/steps.go rename to x-pack/elastic-agent/pkg/agent/transpiler/steps.go index d436999a432..a5538a91a26 100644 --- a/x-pack/agent/pkg/agent/transpiler/steps.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/steps.go @@ -128,12 +128,16 @@ type DeleteFileStep struct { // Execute executes delete file step. func (r *DeleteFileStep) Execute(rootDir string) error { - path, isSubpath := joinPaths(rootDir, r.Path) + path, isSubpath, err := joinPaths(rootDir, r.Path) + if err != nil { + return err + } + if !isSubpath { return fmt.Errorf("invalid path value for operation 'Delete': %s", path) } - err := os.Remove(path) + err = os.Remove(path) if os.IsNotExist(err) && r.FailOnMissing { // is not found and should be reported @@ -166,17 +170,25 @@ type MoveFileStep struct { // Execute executes move file step. func (r *MoveFileStep) Execute(rootDir string) error { - path, isSubpath := joinPaths(rootDir, r.Path) + path, isSubpath, err := joinPaths(rootDir, r.Path) + if err != nil { + return err + } + if !isSubpath { return fmt.Errorf("invalid path value for operation 'Move': %s", path) } - target, isSubpath := joinPaths(rootDir, r.Target) + target, isSubpath, err := joinPaths(rootDir, r.Target) + if err != nil { + return err + } + if !isSubpath { return fmt.Errorf("invalid target value for operation 'Move': %s", target) } - err := os.Rename(path, target) + err = os.Rename(path, target) if os.IsNotExist(err) && r.FailOnMissing { // is not found and should be reported @@ -201,13 +213,28 @@ func MoveFile(path, target string, failOnMissing bool) *MoveFileStep { } // joinPaths joins paths and returns true if path is subpath of rootDir -func joinPaths(rootDir, path string) (string, bool) { +func joinPaths(rootDir, path string) (string, bool, error) { + rootDir = filepath.FromSlash(rootDir) + path = filepath.FromSlash(path) + + if runtime.GOOS == "windows" { + // if is unix absolute fix to win absolute + if strings.HasPrefix(path, "\\") { + abs, err := filepath.Abs(rootDir) // get current volume + if err != nil { + return "", false, err + } + vol := filepath.VolumeName(abs) + path = filepath.Join(vol, path) + } + } + if !filepath.IsAbs(path) { path = filepath.Join(rootDir, path) } - absRoot := filepath.Clean(filepath.FromSlash(rootDir)) - absPath := filepath.Clean(filepath.FromSlash(path)) + absRoot := filepath.Clean(rootDir) + absPath := filepath.Clean(path) // path on windows are case insensitive if !isFsCaseSensitive(rootDir) { @@ -215,7 +242,7 @@ func joinPaths(rootDir, path string) (string, bool) { absPath = strings.ToLower(absPath) } - return absPath, strings.HasPrefix(absPath, absRoot) + return absPath, strings.HasPrefix(absPath, absRoot), nil } func isFsCaseSensitive(rootDir string) bool { diff --git a/x-pack/agent/pkg/agent/transpiler/steps_test.go b/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go similarity index 68% rename from x-pack/agent/pkg/agent/transpiler/steps_test.go rename to x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go index eedff0a703c..d618b1e1993 100644 --- a/x-pack/agent/pkg/agent/transpiler/steps_test.go +++ b/x-pack/elastic-agent/pkg/agent/transpiler/steps_test.go @@ -23,7 +23,9 @@ func TestIsSubpath(t *testing.T) { {"/", "a", "/a", true}, {"/a", "b", "/a/b", true}, {"/a", "b/c", "/a/b/c", true}, + {"/a/b", "/a/c", "/a/c", false}, + {"/a/b", "/a/b/../c", "/a/c", false}, {"/a/b", "../c", "/a/c", false}, {"/a", "/a/b/c", "/a/b/c", true}, @@ -40,14 +42,16 @@ func TestIsSubpath(t *testing.T) { {"/a", "/A/b/c", "/a/b/c", true}, }, "windows": { - {"/", "a", "\\a", true}, - {"/a", "b", "\\a\\b", true}, - {"/a", "b/c", "\\a\\b\\c", true}, - {"/a/b", "/a/c", "\\a\\c", false}, - {"/a/b", "/a/b/../c", "\\a\\c", false}, - {"/a/b", "../c", "\\a\\c", false}, - {"/a", "/a/b/c", "\\a\\b\\c", true}, - {"/a", "/A/b/c", "\\a\\b\\c", true}, + {"c:/", "/a", "c:\\a", true}, + {"c:/a", "b", "c:\\a\\b", true}, + {"c:/a", "b/c", "c:\\a\\b\\c", true}, + {"c:/a/b", "/a/c", "c:\\a\\c", false}, + {"c:/a/b", "/a/b/../c", "c:\\a\\c", false}, + {"c:/a/b", "../c", "c:\\a\\c", false}, + {"c:/a", "/a/b/c", "c:\\a\\b\\c", true}, + {"c:/a", "/A/b/c", "c:\\a\\b\\c", true}, + {"c:/a", "c:/A/b/c", "c:\\a\\b\\c", true}, + {"c:/a", "c:/b/c", "c:\\b\\c", false}, }, } @@ -57,8 +61,9 @@ func TestIsSubpath(t *testing.T) { } for _, test := range osSpecificTests { - t.Run(fmt.Sprintf("[%s]'%s-%s'", runtime.GOOS, test.root, test.path), func(t *testing.T) { - newPath, result := joinPaths(test.root, test.path) + t.Run(fmt.Sprintf("[%s] root:'%s path: %s'", runtime.GOOS, test.root, test.path), func(t *testing.T) { + newPath, result, err := joinPaths(test.root, test.path) + assert.NoError(t, err) assert.Equal(t, test.resultPath, newPath) assert.Equal(t, test.isSubpath, result) }) diff --git a/x-pack/agent/pkg/agent/transpiler/visitor.go b/x-pack/elastic-agent/pkg/agent/transpiler/visitor.go similarity index 100% rename from x-pack/agent/pkg/agent/transpiler/visitor.go rename to x-pack/elastic-agent/pkg/agent/transpiler/visitor.go diff --git a/x-pack/agent/pkg/agent/warn/warn.go b/x-pack/elastic-agent/pkg/agent/warn/warn.go similarity index 90% rename from x-pack/agent/pkg/agent/warn/warn.go rename to x-pack/elastic-agent/pkg/agent/warn/warn.go index ddbbc20132c..d9667f6f284 100644 --- a/x-pack/agent/pkg/agent/warn/warn.go +++ b/x-pack/elastic-agent/pkg/agent/warn/warn.go @@ -8,7 +8,7 @@ import ( "fmt" "io" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) const message = "The Elastic Agent is currently in Alpha and should not be used in production" diff --git a/x-pack/agent/pkg/artifact/artifact.go b/x-pack/elastic-agent/pkg/artifact/artifact.go similarity index 95% rename from x-pack/agent/pkg/artifact/artifact.go rename to x-pack/elastic-agent/pkg/artifact/artifact.go index 1315497dc37..72c9ad06a2a 100644 --- a/x-pack/agent/pkg/artifact/artifact.go +++ b/x-pack/elastic-agent/pkg/artifact/artifact.go @@ -8,7 +8,7 @@ import ( "fmt" "path/filepath" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) var packageArchMap = map[string]string{ diff --git a/x-pack/agent/pkg/artifact/config.go b/x-pack/elastic-agent/pkg/artifact/config.go similarity index 91% rename from x-pack/agent/pkg/artifact/config.go rename to x-pack/elastic-agent/pkg/artifact/config.go index 363cb50c499..406677cb8aa 100644 --- a/x-pack/agent/pkg/artifact/config.go +++ b/x-pack/elastic-agent/pkg/artifact/config.go @@ -28,17 +28,17 @@ type Config struct { Timeout time.Duration `json:"timeout" config:"timeout"` // PgpFile: filepath to a public key used for verifying downloaded artifacts - // if not file is present agent will try to load public key from elastic.co website. + // if not file is present elastic-agent will try to load public key from elastic.co website. PgpFile string `json:"pgpfile" config:"pgpfile"` // InstallPath: path to the directory containing installed packages InstallPath string `yaml:"installPath" config:"install_path"` - // DropPath: path where agent can find installation files for download. + // DropPath: path where elastic-agent can find installation files for download. // Difference between this and TargetDirectory is that when fetching packages (from web or fs) they are stored in TargetDirectory // DropPath specifies where Filesystem downloader can find packages which will then be placed in TargetDirectory. This can be // local or network disk. - // If not provided FileSystem Downloader will fallback to /beats subfolder of agent directory. + // If not provided FileSystem Downloader will fallback to /beats subfolder of elastic-agent directory. DropPath string `yaml:"dropPath" config:"drop_path"` } diff --git a/x-pack/agent/pkg/artifact/download/composed/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/composed/downloader.go similarity index 94% rename from x-pack/agent/pkg/artifact/download/composed/downloader.go rename to x-pack/elastic-agent/pkg/artifact/download/composed/downloader.go index b8132a689b0..c8760861269 100644 --- a/x-pack/agent/pkg/artifact/download/composed/downloader.go +++ b/x-pack/elastic-agent/pkg/artifact/download/composed/downloader.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" ) // Downloader is a downloader with a predefined set of downloaders. diff --git a/x-pack/agent/pkg/artifact/download/composed/downloader_test.go b/x-pack/elastic-agent/pkg/artifact/download/composed/downloader_test.go similarity index 96% rename from x-pack/agent/pkg/artifact/download/composed/downloader_test.go rename to x-pack/elastic-agent/pkg/artifact/download/composed/downloader_test.go index 472d8689ef3..9f720fae235 100644 --- a/x-pack/agent/pkg/artifact/download/composed/downloader_test.go +++ b/x-pack/elastic-agent/pkg/artifact/download/composed/downloader_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" ) type FailingDownloader struct { diff --git a/x-pack/agent/pkg/artifact/download/composed/verifier.go b/x-pack/elastic-agent/pkg/artifact/download/composed/verifier.go similarity index 94% rename from x-pack/agent/pkg/artifact/download/composed/verifier.go rename to x-pack/elastic-agent/pkg/artifact/download/composed/verifier.go index 3c7bb5d81f3..33397a87e1e 100644 --- a/x-pack/agent/pkg/artifact/download/composed/verifier.go +++ b/x-pack/elastic-agent/pkg/artifact/download/composed/verifier.go @@ -7,7 +7,7 @@ package composed import ( "github.com/hashicorp/go-multierror" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" ) // Verifier is a verifier with a predefined set of verifiers. diff --git a/x-pack/agent/pkg/artifact/download/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/downloader.go similarity index 100% rename from x-pack/agent/pkg/artifact/download/downloader.go rename to x-pack/elastic-agent/pkg/artifact/download/downloader.go diff --git a/x-pack/agent/pkg/artifact/download/fs/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/fs/downloader.go similarity index 95% rename from x-pack/agent/pkg/artifact/download/fs/downloader.go rename to x-pack/elastic-agent/pkg/artifact/download/fs/downloader.go index c17ae5dc0e3..490f0b77478 100644 --- a/x-pack/agent/pkg/artifact/download/fs/downloader.go +++ b/x-pack/elastic-agent/pkg/artifact/download/fs/downloader.go @@ -11,8 +11,8 @@ import ( "os" "path/filepath" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const ( diff --git a/x-pack/agent/pkg/artifact/download/fs/verifier.go b/x-pack/elastic-agent/pkg/artifact/download/fs/verifier.go similarity index 95% rename from x-pack/agent/pkg/artifact/download/fs/verifier.go rename to x-pack/elastic-agent/pkg/artifact/download/fs/verifier.go index c8f22b36328..1c06dc4b033 100644 --- a/x-pack/agent/pkg/artifact/download/fs/verifier.go +++ b/x-pack/elastic-agent/pkg/artifact/download/fs/verifier.go @@ -13,8 +13,8 @@ import ( "golang.org/x/crypto/openpgp" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const ( diff --git a/x-pack/agent/pkg/artifact/download/http/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/http/downloader.go similarity index 93% rename from x-pack/agent/pkg/artifact/download/http/downloader.go rename to x-pack/elastic-agent/pkg/artifact/download/http/downloader.go index ad569fbdf7a..7429f3fc137 100644 --- a/x-pack/agent/pkg/artifact/download/http/downloader.go +++ b/x-pack/elastic-agent/pkg/artifact/download/http/downloader.go @@ -14,9 +14,9 @@ import ( "path" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) const ( @@ -24,7 +24,7 @@ const ( ) var headers = map[string]string{ - "User-Agent": fmt.Sprintf("Beat agent v%s", release.Version()), + "User-Agent": fmt.Sprintf("Beat elastic-agent v%s", release.Version()), } // Downloader is a downloader able to fetch artifacts from elastic.co web page. diff --git a/x-pack/agent/pkg/artifact/download/http/elastic_test.go b/x-pack/elastic-agent/pkg/artifact/download/http/elastic_test.go similarity index 98% rename from x-pack/agent/pkg/artifact/download/http/elastic_test.go rename to x-pack/elastic-agent/pkg/artifact/download/http/elastic_test.go index f13226b1923..ba0f1cffbda 100644 --- a/x-pack/agent/pkg/artifact/download/http/elastic_test.go +++ b/x-pack/elastic-agent/pkg/artifact/download/http/elastic_test.go @@ -16,7 +16,7 @@ import ( "testing" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const ( diff --git a/x-pack/agent/pkg/artifact/download/http/headers_rtt.go b/x-pack/elastic-agent/pkg/artifact/download/http/headers_rtt.go similarity index 100% rename from x-pack/agent/pkg/artifact/download/http/headers_rtt.go rename to x-pack/elastic-agent/pkg/artifact/download/http/headers_rtt.go diff --git a/x-pack/agent/pkg/artifact/download/http/headers_rtt_test.go b/x-pack/elastic-agent/pkg/artifact/download/http/headers_rtt_test.go similarity index 83% rename from x-pack/agent/pkg/artifact/download/http/headers_rtt_test.go rename to x-pack/elastic-agent/pkg/artifact/download/http/headers_rtt_test.go index 31041296da6..06675b6f466 100644 --- a/x-pack/agent/pkg/artifact/download/http/headers_rtt_test.go +++ b/x-pack/elastic-agent/pkg/artifact/download/http/headers_rtt_test.go @@ -14,13 +14,13 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func TestAddingHeaders(t *testing.T) { msg := []byte("OK") server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - assert.Equal(t, fmt.Sprintf("Beat agent v%s", release.Version()), req.Header.Get("User-Agent")) + assert.Equal(t, fmt.Sprintf("Beat elastic-agent v%s", release.Version()), req.Header.Get("User-Agent")) w.Write(msg) })) defer server.Close() diff --git a/x-pack/agent/pkg/artifact/download/http/verifier.go b/x-pack/elastic-agent/pkg/artifact/download/http/verifier.go similarity index 97% rename from x-pack/agent/pkg/artifact/download/http/verifier.go rename to x-pack/elastic-agent/pkg/artifact/download/http/verifier.go index dc5395d4e97..f1f6475c1b6 100644 --- a/x-pack/agent/pkg/artifact/download/http/verifier.go +++ b/x-pack/elastic-agent/pkg/artifact/download/http/verifier.go @@ -16,8 +16,8 @@ import ( "golang.org/x/crypto/openpgp" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const ( diff --git a/x-pack/agent/pkg/artifact/download/localremote/downloader.go b/x-pack/elastic-agent/pkg/artifact/download/localremote/downloader.go similarity index 60% rename from x-pack/agent/pkg/artifact/download/localremote/downloader.go rename to x-pack/elastic-agent/pkg/artifact/download/localremote/downloader.go index 7faf6a500dd..8757cb2abbc 100644 --- a/x-pack/agent/pkg/artifact/download/localremote/downloader.go +++ b/x-pack/elastic-agent/pkg/artifact/download/localremote/downloader.go @@ -5,11 +5,11 @@ package localremote import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/composed" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/fs" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/http" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/composed" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/fs" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/http" ) // NewDownloader creates a downloader which first checks local directory diff --git a/x-pack/agent/pkg/artifact/download/localremote/verifier.go b/x-pack/elastic-agent/pkg/artifact/download/localremote/verifier.go similarity index 65% rename from x-pack/agent/pkg/artifact/download/localremote/verifier.go rename to x-pack/elastic-agent/pkg/artifact/download/localremote/verifier.go index c4570aee2ee..08cb61cb7c3 100644 --- a/x-pack/agent/pkg/artifact/download/localremote/verifier.go +++ b/x-pack/elastic-agent/pkg/artifact/download/localremote/verifier.go @@ -5,11 +5,11 @@ package localremote import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/composed" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/fs" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/download/http" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/composed" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/fs" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/download/http" ) // NewVerifier creates a downloader which first checks local directory diff --git a/x-pack/agent/pkg/artifact/download/verifier.go b/x-pack/elastic-agent/pkg/artifact/download/verifier.go similarity index 100% rename from x-pack/agent/pkg/artifact/download/verifier.go rename to x-pack/elastic-agent/pkg/artifact/download/verifier.go diff --git a/x-pack/agent/pkg/artifact/install/hooks/hooks_installer.go b/x-pack/elastic-agent/pkg/artifact/install/hooks/hooks_installer.go similarity index 94% rename from x-pack/agent/pkg/artifact/install/hooks/hooks_installer.go rename to x-pack/elastic-agent/pkg/artifact/install/hooks/hooks_installer.go index 8dd4c8c057f..fd2f4e4bfdb 100644 --- a/x-pack/agent/pkg/artifact/install/hooks/hooks_installer.go +++ b/x-pack/elastic-agent/pkg/artifact/install/hooks/hooks_installer.go @@ -7,7 +7,7 @@ package hooks import ( "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" ) type embeddedInstaller interface { diff --git a/x-pack/agent/pkg/artifact/install/installer.go b/x-pack/elastic-agent/pkg/artifact/install/installer.go similarity index 80% rename from x-pack/agent/pkg/artifact/install/installer.go rename to x-pack/elastic-agent/pkg/artifact/install/installer.go index 0ba1a07aca6..4856468ac83 100644 --- a/x-pack/agent/pkg/artifact/install/installer.go +++ b/x-pack/elastic-agent/pkg/artifact/install/installer.go @@ -8,10 +8,10 @@ import ( "errors" "runtime" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install/hooks" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install/tar" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact/install/zip" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install/hooks" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install/tar" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact/install/zip" ) var ( diff --git a/x-pack/agent/pkg/artifact/install/tar/tar_installer.go b/x-pack/elastic-agent/pkg/artifact/install/tar/tar_installer.go similarity index 96% rename from x-pack/agent/pkg/artifact/install/tar/tar_installer.go rename to x-pack/elastic-agent/pkg/artifact/install/tar/tar_installer.go index 1b5e28a23ee..52d49f627f5 100644 --- a/x-pack/agent/pkg/artifact/install/tar/tar_installer.go +++ b/x-pack/elastic-agent/pkg/artifact/install/tar/tar_installer.go @@ -13,8 +13,8 @@ import ( "path/filepath" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) // Installer or tar packages diff --git a/x-pack/agent/pkg/artifact/install/zip/zip_installer.go b/x-pack/elastic-agent/pkg/artifact/install/zip/zip_installer.go similarity index 95% rename from x-pack/agent/pkg/artifact/install/zip/zip_installer.go rename to x-pack/elastic-agent/pkg/artifact/install/zip/zip_installer.go index f71b1e6f71a..5293e49f016 100644 --- a/x-pack/agent/pkg/artifact/install/zip/zip_installer.go +++ b/x-pack/elastic-agent/pkg/artifact/install/zip/zip_installer.go @@ -11,8 +11,8 @@ import ( "os/exec" "path/filepath" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const ( diff --git a/x-pack/agent/pkg/basecmd/cmd.go b/x-pack/elastic-agent/pkg/basecmd/cmd.go similarity index 80% rename from x-pack/agent/pkg/basecmd/cmd.go rename to x-pack/elastic-agent/pkg/basecmd/cmd.go index cfe3631e5bf..9b957916fb1 100644 --- a/x-pack/agent/pkg/basecmd/cmd.go +++ b/x-pack/elastic-agent/pkg/basecmd/cmd.go @@ -7,8 +7,8 @@ package basecmd import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/x-pack/agent/pkg/basecmd/version" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/basecmd/version" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" ) // NewDefaultCommandsWithArgs returns a list of default commands to executes. diff --git a/x-pack/agent/pkg/basecmd/cmd_test.go b/x-pack/elastic-agent/pkg/basecmd/cmd_test.go similarity index 87% rename from x-pack/agent/pkg/basecmd/cmd_test.go rename to x-pack/elastic-agent/pkg/basecmd/cmd_test.go index accc4bc976e..7dbdc51f8f2 100644 --- a/x-pack/agent/pkg/basecmd/cmd_test.go +++ b/x-pack/elastic-agent/pkg/basecmd/cmd_test.go @@ -7,7 +7,7 @@ package basecmd import ( "testing" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" ) func TestBaseCmd(t *testing.T) { diff --git a/x-pack/agent/pkg/basecmd/version/cmd.go b/x-pack/elastic-agent/pkg/basecmd/version/cmd.go similarity index 81% rename from x-pack/agent/pkg/basecmd/version/cmd.go rename to x-pack/elastic-agent/pkg/basecmd/version/cmd.go index b2de26fd1d4..0bf25438e80 100644 --- a/x-pack/agent/pkg/basecmd/version/cmd.go +++ b/x-pack/elastic-agent/pkg/basecmd/version/cmd.go @@ -9,15 +9,15 @@ import ( "github.com/spf13/cobra" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) // NewCommandWithArgs returns a new version command. func NewCommandWithArgs(streams *cli.IOStreams) *cobra.Command { return &cobra.Command{ Use: "version", - Short: "Display the version of the agent.", + Short: "Display the version of the elastic-agent.", Run: func(_ *cobra.Command, _ []string) { version := release.Version() if release.Snapshot() { diff --git a/x-pack/agent/pkg/basecmd/version/cmd_test.go b/x-pack/elastic-agent/pkg/basecmd/version/cmd_test.go similarity index 91% rename from x-pack/agent/pkg/basecmd/version/cmd_test.go rename to x-pack/elastic-agent/pkg/basecmd/version/cmd_test.go index 0395e604b42..111d174608f 100644 --- a/x-pack/agent/pkg/basecmd/version/cmd_test.go +++ b/x-pack/elastic-agent/pkg/basecmd/version/cmd_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/cli" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/cli" ) func TestCmd(t *testing.T) { diff --git a/x-pack/agent/pkg/boolexp/Boolexp.g4 b/x-pack/elastic-agent/pkg/boolexp/Boolexp.g4 similarity index 100% rename from x-pack/agent/pkg/boolexp/Boolexp.g4 rename to x-pack/elastic-agent/pkg/boolexp/Boolexp.g4 diff --git a/x-pack/agent/pkg/boolexp/boolexp.go b/x-pack/elastic-agent/pkg/boolexp/boolexp.go similarity index 100% rename from x-pack/agent/pkg/boolexp/boolexp.go rename to x-pack/elastic-agent/pkg/boolexp/boolexp.go diff --git a/x-pack/agent/pkg/boolexp/boolexp_test.go b/x-pack/elastic-agent/pkg/boolexp/boolexp_test.go similarity index 99% rename from x-pack/agent/pkg/boolexp/boolexp_test.go rename to x-pack/elastic-agent/pkg/boolexp/boolexp_test.go index 4e61f44ab47..44faa8e2bb0 100644 --- a/x-pack/agent/pkg/boolexp/boolexp_test.go +++ b/x-pack/elastic-agent/pkg/boolexp/boolexp_test.go @@ -14,7 +14,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp/parser" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp/parser" ) var showDebug = lookupEnvOrDefault("DEBUG", "0") diff --git a/x-pack/agent/pkg/boolexp/compare.go b/x-pack/elastic-agent/pkg/boolexp/compare.go similarity index 100% rename from x-pack/agent/pkg/boolexp/compare.go rename to x-pack/elastic-agent/pkg/boolexp/compare.go diff --git a/x-pack/agent/pkg/boolexp/expression.go b/x-pack/elastic-agent/pkg/boolexp/expression.go similarity index 96% rename from x-pack/agent/pkg/boolexp/expression.go rename to x-pack/elastic-agent/pkg/boolexp/expression.go index c7c5f12a164..69d30603d5c 100644 --- a/x-pack/agent/pkg/boolexp/expression.go +++ b/x-pack/elastic-agent/pkg/boolexp/expression.go @@ -10,7 +10,7 @@ import ( "github.com/antlr/antlr4/runtime/Go/antlr" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp/parser" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp/parser" ) // VarStore is the interface to implements when you want the expression engine to be able to fetch diff --git a/x-pack/agent/pkg/boolexp/methods.go b/x-pack/elastic-agent/pkg/boolexp/methods.go similarity index 100% rename from x-pack/agent/pkg/boolexp/methods.go rename to x-pack/elastic-agent/pkg/boolexp/methods.go diff --git a/x-pack/agent/pkg/boolexp/parser/Boolexp.interp b/x-pack/elastic-agent/pkg/boolexp/parser/Boolexp.interp similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/Boolexp.interp rename to x-pack/elastic-agent/pkg/boolexp/parser/Boolexp.interp diff --git a/x-pack/agent/pkg/boolexp/parser/Boolexp.tokens b/x-pack/elastic-agent/pkg/boolexp/parser/Boolexp.tokens similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/Boolexp.tokens rename to x-pack/elastic-agent/pkg/boolexp/parser/Boolexp.tokens diff --git a/x-pack/agent/pkg/boolexp/parser/BoolexpLexer.interp b/x-pack/elastic-agent/pkg/boolexp/parser/BoolexpLexer.interp similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/BoolexpLexer.interp rename to x-pack/elastic-agent/pkg/boolexp/parser/BoolexpLexer.interp diff --git a/x-pack/agent/pkg/boolexp/parser/BoolexpLexer.tokens b/x-pack/elastic-agent/pkg/boolexp/parser/BoolexpLexer.tokens similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/BoolexpLexer.tokens rename to x-pack/elastic-agent/pkg/boolexp/parser/BoolexpLexer.tokens diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_base_listener.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_base_listener.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_base_listener.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_base_listener.go diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_base_visitor.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_base_visitor.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_base_visitor.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_base_visitor.go diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_lexer.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_lexer.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_lexer.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_lexer.go diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_listener.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_listener.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_listener.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_listener.go diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_parser.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_parser.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_parser.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_parser.go diff --git a/x-pack/agent/pkg/boolexp/parser/boolexp_visitor.go b/x-pack/elastic-agent/pkg/boolexp/parser/boolexp_visitor.go similarity index 100% rename from x-pack/agent/pkg/boolexp/parser/boolexp_visitor.go rename to x-pack/elastic-agent/pkg/boolexp/parser/boolexp_visitor.go diff --git a/x-pack/agent/pkg/boolexp/visitor.go b/x-pack/elastic-agent/pkg/boolexp/visitor.go similarity index 98% rename from x-pack/agent/pkg/boolexp/visitor.go rename to x-pack/elastic-agent/pkg/boolexp/visitor.go index 1f640986ac4..40264a4e6e1 100644 --- a/x-pack/agent/pkg/boolexp/visitor.go +++ b/x-pack/elastic-agent/pkg/boolexp/visitor.go @@ -11,7 +11,7 @@ import ( "github.com/antlr/antlr4/runtime/Go/antlr" - "github.com/elastic/beats/v7/x-pack/agent/pkg/boolexp/parser" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/boolexp/parser" ) // Errors diff --git a/x-pack/agent/pkg/cli/flags.go b/x-pack/elastic-agent/pkg/cli/flags.go similarity index 100% rename from x-pack/agent/pkg/cli/flags.go rename to x-pack/elastic-agent/pkg/cli/flags.go diff --git a/x-pack/agent/pkg/cli/flags_test.go b/x-pack/elastic-agent/pkg/cli/flags_test.go similarity index 100% rename from x-pack/agent/pkg/cli/flags_test.go rename to x-pack/elastic-agent/pkg/cli/flags_test.go diff --git a/x-pack/agent/pkg/cli/streams.go b/x-pack/elastic-agent/pkg/cli/streams.go similarity index 100% rename from x-pack/agent/pkg/cli/streams.go rename to x-pack/elastic-agent/pkg/cli/streams.go diff --git a/x-pack/agent/pkg/config/config.go b/x-pack/elastic-agent/pkg/config/config.go similarity index 100% rename from x-pack/agent/pkg/config/config.go rename to x-pack/elastic-agent/pkg/config/config.go diff --git a/x-pack/agent/pkg/config/config_test.go b/x-pack/elastic-agent/pkg/config/config_test.go similarity index 100% rename from x-pack/agent/pkg/config/config_test.go rename to x-pack/elastic-agent/pkg/config/config_test.go diff --git a/x-pack/agent/pkg/core/logger/logger.go b/x-pack/elastic-agent/pkg/core/logger/logger.go similarity index 94% rename from x-pack/agent/pkg/core/logger/logger.go rename to x-pack/elastic-agent/pkg/core/logger/logger.go index 3d6889a3542..3f23feb782e 100644 --- a/x-pack/agent/pkg/core/logger/logger.go +++ b/x-pack/elastic-agent/pkg/core/logger/logger.go @@ -10,7 +10,7 @@ import ( "github.com/urso/ecslog/backend/appender" "github.com/urso/ecslog/backend/layout" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" ) // Logger alias ecslog.Logger with Logger. diff --git a/x-pack/agent/pkg/core/logger/logger_test.go b/x-pack/elastic-agent/pkg/core/logger/logger_test.go similarity index 100% rename from x-pack/agent/pkg/core/logger/logger_test.go rename to x-pack/elastic-agent/pkg/core/logger/logger_test.go diff --git a/x-pack/agent/pkg/core/plugin/app/app.go b/x-pack/elastic-agent/pkg/core/plugin/app/app.go similarity index 85% rename from x-pack/agent/pkg/core/plugin/app/app.go rename to x-pack/elastic-agent/pkg/core/plugin/app/app.go index e8acb42895f..1889eed5182 100644 --- a/x-pack/agent/pkg/core/plugin/app/app.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/app.go @@ -12,16 +12,16 @@ import ( "sync" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/operation/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" - "github.com/elastic/beats/v7/x-pack/agent/pkg/tokenbucket" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/operation/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/tokenbucket" ) var ( @@ -36,7 +36,7 @@ var ( // ReportFailureFunc is a callback func used to report async failures due to crashes. type ReportFailureFunc func(context.Context, string, error) -// Application encapsulates a concrete application ran by agent e.g Beat. +// Application encapsulates a concrete application ran by elastic-agent e.g Beat. type Application struct { id string name string diff --git a/x-pack/agent/pkg/core/plugin/app/client.go b/x-pack/elastic-agent/pkg/core/plugin/app/client.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/client.go rename to x-pack/elastic-agent/pkg/core/plugin/app/client.go diff --git a/x-pack/agent/pkg/core/plugin/app/configure.go b/x-pack/elastic-agent/pkg/core/plugin/app/configure.go similarity index 87% rename from x-pack/agent/pkg/core/plugin/app/configure.go rename to x-pack/elastic-agent/pkg/core/plugin/app/configure.go index f75a01d6dd2..3feb3020c9b 100644 --- a/x-pack/agent/pkg/core/plugin/app/configure.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/configure.go @@ -12,10 +12,10 @@ import ( "gopkg.in/yaml.v2" "github.com/elastic/beats/v7/libbeat/common/backoff" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/retry" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/retry" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" ) const ( diff --git a/x-pack/agent/pkg/core/plugin/app/descriptor.go b/x-pack/elastic-agent/pkg/core/plugin/app/descriptor.go similarity index 96% rename from x-pack/agent/pkg/core/plugin/app/descriptor.go rename to x-pack/elastic-agent/pkg/core/plugin/app/descriptor.go index 1b4072e39eb..3dc5f0e00d3 100644 --- a/x-pack/agent/pkg/core/plugin/app/descriptor.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/descriptor.go @@ -9,8 +9,8 @@ import ( "path/filepath" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/program" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/program" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) // Descriptor defines a program which needs to be run. diff --git a/x-pack/agent/pkg/core/plugin/app/execution_context.go b/x-pack/elastic-agent/pkg/core/plugin/app/execution_context.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/execution_context.go rename to x-pack/elastic-agent/pkg/core/plugin/app/execution_context.go diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go similarity index 98% rename from x-pack/agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go index d749fbc02d3..eda80bf1ffe 100644 --- a/x-pack/agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/beats_monitor.go @@ -11,7 +11,7 @@ import ( "strings" "unicode" - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" ) const httpPlusPrefix = "http+" diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/beats/drop_test.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/drop_test.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/monitoring/beats/drop_test.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/drop_test.go diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/beats/monitoring.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/monitoring/beats/monitoring.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats/monitoring.go diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/config.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/config.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/monitoring/config.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/config.go diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/monitor.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go similarity index 79% rename from x-pack/agent/pkg/core/plugin/app/monitoring/monitor.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go index ed820cd0ebe..dd4744de8ee 100644 --- a/x-pack/agent/pkg/core/plugin/app/monitoring/monitor.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/monitor.go @@ -5,9 +5,9 @@ package monitoring import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/artifact" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring/beats" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/app/monitoring/noop" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/artifact" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/beats" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/noop" ) // Monitor is a monitoring interface providing information about the way diff --git a/x-pack/agent/pkg/core/plugin/app/monitoring/noop/noop_monitor.go b/x-pack/elastic-agent/pkg/core/plugin/app/monitoring/noop/noop_monitor.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/monitoring/noop/noop_monitor.go rename to x-pack/elastic-agent/pkg/core/plugin/app/monitoring/noop/noop_monitor.go diff --git a/x-pack/agent/pkg/core/plugin/app/process_cred.go b/x-pack/elastic-agent/pkg/core/plugin/app/process_cred.go similarity index 95% rename from x-pack/agent/pkg/core/plugin/app/process_cred.go rename to x-pack/elastic-agent/pkg/core/plugin/app/process_cred.go index 2b288b634d8..aaae763209d 100644 --- a/x-pack/agent/pkg/core/plugin/app/process_cred.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/process_cred.go @@ -11,7 +11,7 @@ import ( "os/user" "strconv" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) func getUserGroup(spec ProcessSpec) (int, int, error) { diff --git a/x-pack/agent/pkg/core/plugin/app/process_cred_other.go b/x-pack/elastic-agent/pkg/core/plugin/app/process_cred_other.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/process_cred_other.go rename to x-pack/elastic-agent/pkg/core/plugin/app/process_cred_other.go diff --git a/x-pack/agent/pkg/core/plugin/app/spec.go b/x-pack/elastic-agent/pkg/core/plugin/app/spec.go similarity index 78% rename from x-pack/agent/pkg/core/plugin/app/spec.go rename to x-pack/elastic-agent/pkg/core/plugin/app/spec.go index 1dbd56ae612..1fc43e71ca2 100644 --- a/x-pack/agent/pkg/core/plugin/app/spec.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/spec.go @@ -9,9 +9,9 @@ import ( ) const ( - // ConfigurableGrpc is a flag telling agent that program has capability of Grpc server with a Config endpoint + // ConfigurableGrpc is a flag telling elastic-agent that program has capability of Grpc server with a Config endpoint ConfigurableGrpc = "grpc" - // ConfigurableFile is a flag telling agent that program has capability of being configured by accepting `-c filepath` + // ConfigurableFile is a flag telling elastic-agent that program has capability of being configured by accepting `-c filepath` // argument with a configuration file provided ConfigurableFile = "file" ) @@ -39,5 +39,5 @@ type ProcessSpec struct { User user.User Group user.Group - // TODO: mapping transformation rules for configuration between agent.yml and to the beats. + // TODO: mapping transformation rules for configuration between elastic-agent.yml and to the beats. } diff --git a/x-pack/agent/pkg/core/plugin/app/start.go b/x-pack/elastic-agent/pkg/core/plugin/app/start.go similarity index 94% rename from x-pack/agent/pkg/core/plugin/app/start.go rename to x-pack/elastic-agent/pkg/core/plugin/app/start.go index 818024e50dd..a95aee7515a 100644 --- a/x-pack/agent/pkg/core/plugin/app/start.go +++ b/x-pack/elastic-agent/pkg/core/plugin/app/start.go @@ -15,12 +15,12 @@ import ( "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/authority" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/state" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig/grpc" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/authority" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/state" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" ) const ( @@ -29,7 +29,7 @@ const ( configFilePermissions = 0644 // writable only by owner ) -// ConfiguratorClient is the client connecting agent and a process +// ConfiguratorClient is the client connecting elastic-agent and a process type stateClient interface { Status(ctx context.Context) (string, error) Close() error diff --git a/x-pack/agent/pkg/core/plugin/app/tag.go b/x-pack/elastic-agent/pkg/core/plugin/app/tag.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/tag.go rename to x-pack/elastic-agent/pkg/core/plugin/app/tag.go diff --git a/x-pack/agent/pkg/core/plugin/app/watch_posix.go b/x-pack/elastic-agent/pkg/core/plugin/app/watch_posix.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/watch_posix.go rename to x-pack/elastic-agent/pkg/core/plugin/app/watch_posix.go diff --git a/x-pack/agent/pkg/core/plugin/app/watch_windows.go b/x-pack/elastic-agent/pkg/core/plugin/app/watch_windows.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/app/watch_windows.go rename to x-pack/elastic-agent/pkg/core/plugin/app/watch_windows.go diff --git a/x-pack/agent/pkg/core/plugin/authority/ca.go b/x-pack/elastic-agent/pkg/core/plugin/authority/ca.go similarity index 98% rename from x-pack/agent/pkg/core/plugin/authority/ca.go rename to x-pack/elastic-agent/pkg/core/plugin/authority/ca.go index f57c3ae2a49..1e477d7808b 100644 --- a/x-pack/agent/pkg/core/plugin/authority/ca.go +++ b/x-pack/elastic-agent/pkg/core/plugin/authority/ca.go @@ -17,7 +17,7 @@ import ( "math/big" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // CertificateAuthority is an abstraction for common certificate authority diff --git a/x-pack/agent/pkg/core/plugin/process/cmd.go b/x-pack/elastic-agent/pkg/core/plugin/process/cmd.go similarity index 89% rename from x-pack/agent/pkg/core/plugin/process/cmd.go rename to x-pack/elastic-agent/pkg/core/plugin/process/cmd.go index dad8fa39ee3..98d3abe30e8 100644 --- a/x-pack/agent/pkg/core/plugin/process/cmd.go +++ b/x-pack/elastic-agent/pkg/core/plugin/process/cmd.go @@ -11,7 +11,7 @@ import ( "os" "os/exec" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func getCmd(logger *logger.Logger, path string, env []string, uid, gid int, arg ...string) *exec.Cmd { diff --git a/x-pack/agent/pkg/core/plugin/process/cmd_cred.go b/x-pack/elastic-agent/pkg/core/plugin/process/cmd_cred.go similarity index 93% rename from x-pack/agent/pkg/core/plugin/process/cmd_cred.go rename to x-pack/elastic-agent/pkg/core/plugin/process/cmd_cred.go index 054cbe290ae..ae254e99897 100644 --- a/x-pack/agent/pkg/core/plugin/process/cmd_cred.go +++ b/x-pack/elastic-agent/pkg/core/plugin/process/cmd_cred.go @@ -12,7 +12,7 @@ import ( "path/filepath" "syscall" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func getCmd(logger *logger.Logger, path string, env []string, uid, gid int, arg ...string) *exec.Cmd { diff --git a/x-pack/agent/pkg/core/plugin/process/config.go b/x-pack/elastic-agent/pkg/core/plugin/process/config.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/process/config.go rename to x-pack/elastic-agent/pkg/core/plugin/process/config.go diff --git a/x-pack/agent/pkg/core/plugin/process/process.go b/x-pack/elastic-agent/pkg/core/plugin/process/process.go similarity index 97% rename from x-pack/agent/pkg/core/plugin/process/process.go rename to x-pack/elastic-agent/pkg/core/plugin/process/process.go index a612e4a8352..3ce192ced44 100644 --- a/x-pack/agent/pkg/core/plugin/process/process.go +++ b/x-pack/elastic-agent/pkg/core/plugin/process/process.go @@ -19,8 +19,8 @@ import ( "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) const ( diff --git a/x-pack/agent/pkg/core/plugin/retry/config.go b/x-pack/elastic-agent/pkg/core/plugin/retry/config.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/retry/config.go rename to x-pack/elastic-agent/pkg/core/plugin/retry/config.go diff --git a/x-pack/agent/pkg/core/plugin/retry/error.go b/x-pack/elastic-agent/pkg/core/plugin/retry/error.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/retry/error.go rename to x-pack/elastic-agent/pkg/core/plugin/retry/error.go diff --git a/x-pack/agent/pkg/core/plugin/retry/retrystrategy.go b/x-pack/elastic-agent/pkg/core/plugin/retry/retrystrategy.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/retry/retrystrategy.go rename to x-pack/elastic-agent/pkg/core/plugin/retry/retrystrategy.go diff --git a/x-pack/agent/pkg/core/plugin/retry/retrystrategy_test.go b/x-pack/elastic-agent/pkg/core/plugin/retry/retrystrategy_test.go similarity index 100% rename from x-pack/agent/pkg/core/plugin/retry/retrystrategy_test.go rename to x-pack/elastic-agent/pkg/core/plugin/retry/retrystrategy_test.go diff --git a/x-pack/agent/pkg/core/plugin/server/server.go b/x-pack/elastic-agent/pkg/core/plugin/server/server.go similarity index 91% rename from x-pack/agent/pkg/core/plugin/server/server.go rename to x-pack/elastic-agent/pkg/core/plugin/server/server.go index cd7eb46e4ae..7f15c22198d 100644 --- a/x-pack/agent/pkg/core/plugin/server/server.go +++ b/x-pack/elastic-agent/pkg/core/plugin/server/server.go @@ -17,9 +17,9 @@ import ( "google.golang.org/grpc/credentials" "gopkg.in/yaml.v2" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig/grpc" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" ) const ( diff --git a/x-pack/agent/pkg/core/plugin/state/state.go b/x-pack/elastic-agent/pkg/core/plugin/state/state.go similarity index 89% rename from x-pack/agent/pkg/core/plugin/state/state.go rename to x-pack/elastic-agent/pkg/core/plugin/state/state.go index 210517e35a8..0c6b35dbc91 100644 --- a/x-pack/agent/pkg/core/plugin/state/state.go +++ b/x-pack/elastic-agent/pkg/core/plugin/state/state.go @@ -4,7 +4,7 @@ package state -import "github.com/elastic/beats/v7/x-pack/agent/pkg/core/plugin/process" +import "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/process" // Status describes the current status of the application process. type Status int diff --git a/x-pack/agent/pkg/core/remoteconfig/config.go b/x-pack/elastic-agent/pkg/core/remoteconfig/config.go similarity index 100% rename from x-pack/agent/pkg/core/remoteconfig/config.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/config.go diff --git a/x-pack/agent/pkg/core/remoteconfig/grpc/configclient.go b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/configclient.go similarity index 97% rename from x-pack/agent/pkg/core/remoteconfig/grpc/configclient.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/grpc/configclient.go index d211643ef42..1ca7ba6b33e 100644 --- a/x-pack/agent/pkg/core/remoteconfig/grpc/configclient.go +++ b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/configclient.go @@ -13,7 +13,7 @@ import ( rpc "google.golang.org/grpc" "github.com/elastic/beats/v7/libbeat/common/backoff" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" ) var ( diff --git a/x-pack/agent/pkg/core/remoteconfig/grpc/connection_provider.go b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/connection_provider.go similarity index 96% rename from x-pack/agent/pkg/core/remoteconfig/grpc/connection_provider.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/grpc/connection_provider.go index 19bf9fa9a88..f6bc612507d 100644 --- a/x-pack/agent/pkg/core/remoteconfig/grpc/connection_provider.go +++ b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/connection_provider.go @@ -5,7 +5,7 @@ package grpc import ( - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" ) var _ remoteconfig.ConnectionProvider = (*ConnectionProvider)(nil) diff --git a/x-pack/agent/pkg/core/remoteconfig/grpc/factory.go b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/factory.go similarity index 93% rename from x-pack/agent/pkg/core/remoteconfig/grpc/factory.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/grpc/factory.go index 386a2b69ea7..62ddb418be9 100644 --- a/x-pack/agent/pkg/core/remoteconfig/grpc/factory.go +++ b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/factory.go @@ -13,8 +13,8 @@ import ( rpc "google.golang.org/grpc" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/remoteconfig" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig" ) // NewConnFactory creates a factory used to create connection. Hides implementation details diff --git a/x-pack/agent/pkg/core/remoteconfig/grpc/noop_backoff.go b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/noop_backoff.go similarity index 100% rename from x-pack/agent/pkg/core/remoteconfig/grpc/noop_backoff.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/grpc/noop_backoff.go diff --git a/x-pack/agent/pkg/core/remoteconfig/grpc/remote_config.pb.go b/x-pack/elastic-agent/pkg/core/remoteconfig/grpc/remote_config.pb.go similarity index 100% rename from x-pack/agent/pkg/core/remoteconfig/grpc/remote_config.pb.go rename to x-pack/elastic-agent/pkg/core/remoteconfig/grpc/remote_config.pb.go diff --git a/x-pack/agent/pkg/crypto/io.go b/x-pack/elastic-agent/pkg/crypto/io.go similarity index 100% rename from x-pack/agent/pkg/crypto/io.go rename to x-pack/elastic-agent/pkg/crypto/io.go diff --git a/x-pack/agent/pkg/crypto/io_test.go b/x-pack/elastic-agent/pkg/crypto/io_test.go similarity index 100% rename from x-pack/agent/pkg/crypto/io_test.go rename to x-pack/elastic-agent/pkg/crypto/io_test.go diff --git a/x-pack/agent/pkg/dir/discover.go b/x-pack/elastic-agent/pkg/dir/discover.go similarity index 92% rename from x-pack/agent/pkg/dir/discover.go rename to x-pack/elastic-agent/pkg/dir/discover.go index 7ef889f23cd..7859469f228 100644 --- a/x-pack/agent/pkg/dir/discover.go +++ b/x-pack/elastic-agent/pkg/dir/discover.go @@ -7,7 +7,7 @@ package dir import ( "path/filepath" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // DiscoverFiles takes a slices of wildcards patterns and try to discover all the matching files diff --git a/x-pack/agent/pkg/dir/discover_test.go b/x-pack/elastic-agent/pkg/dir/discover_test.go similarity index 90% rename from x-pack/agent/pkg/dir/discover_test.go rename to x-pack/elastic-agent/pkg/dir/discover_test.go index ad7cb21bf68..153e94d0304 100644 --- a/x-pack/agent/pkg/dir/discover_test.go +++ b/x-pack/elastic-agent/pkg/dir/discover_test.go @@ -14,6 +14,8 @@ import ( "github.com/stretchr/testify/require" ) +const agentConfigFile = "elastic-agent.yml" + func TestDiscover(t *testing.T) { t.Run("support wildcards patterns", withFiles([]string{"hello", "helllooo"}, func( dst string, @@ -33,19 +35,19 @@ func TestDiscover(t *testing.T) { assert.Equal(t, 1, len(r)) })) - t.Run("support direct file and pattern", withFiles([]string{"hello", "helllooo", "agent.yml"}, func( + t.Run("support direct file and pattern", withFiles([]string{"hello", "helllooo", agentConfigFile}, func( dst string, t *testing.T, ) { r, err := DiscoverFiles( filepath.Join(dst, "hel*"), - filepath.Join(dst, "agent.yml"), + filepath.Join(dst, agentConfigFile), ) require.NoError(t, err) assert.Equal(t, 3, len(r)) })) - t.Run("support direct file and pattern", withFiles([]string{"hello", "helllooo", "agent.yml"}, func( + t.Run("support direct file and pattern", withFiles([]string{"hello", "helllooo", agentConfigFile}, func( dst string, t *testing.T, ) { diff --git a/x-pack/agent/pkg/filewatcher/watcher.go b/x-pack/elastic-agent/pkg/filewatcher/watcher.go similarity index 97% rename from x-pack/agent/pkg/filewatcher/watcher.go rename to x-pack/elastic-agent/pkg/filewatcher/watcher.go index cb64d6f2a60..32d96436b88 100644 --- a/x-pack/agent/pkg/filewatcher/watcher.go +++ b/x-pack/elastic-agent/pkg/filewatcher/watcher.go @@ -12,8 +12,8 @@ import ( "sort" "sync" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) // Comparer receives a file and the saved information about that file from the previous scan, diff --git a/x-pack/agent/pkg/filewatcher/watcher_test.go b/x-pack/elastic-agent/pkg/filewatcher/watcher_test.go similarity index 100% rename from x-pack/agent/pkg/filewatcher/watcher_test.go rename to x-pack/elastic-agent/pkg/filewatcher/watcher_test.go diff --git a/x-pack/agent/pkg/fleetapi/ack_cmd.go b/x-pack/elastic-agent/pkg/fleetapi/ack_cmd.go similarity index 97% rename from x-pack/agent/pkg/fleetapi/ack_cmd.go rename to x-pack/elastic-agent/pkg/fleetapi/ack_cmd.go index 693fb295a6c..a1b1a245114 100644 --- a/x-pack/agent/pkg/fleetapi/ack_cmd.go +++ b/x-pack/elastic-agent/pkg/fleetapi/ack_cmd.go @@ -11,7 +11,7 @@ import ( "fmt" "net/http" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) const ackPath = "/api/ingest_manager/fleet/agents/%s/acks" diff --git a/x-pack/agent/pkg/fleetapi/ack_cmd_test.go b/x-pack/elastic-agent/pkg/fleetapi/ack_cmd_test.go similarity index 100% rename from x-pack/agent/pkg/fleetapi/ack_cmd_test.go rename to x-pack/elastic-agent/pkg/fleetapi/ack_cmd_test.go diff --git a/x-pack/agent/pkg/fleetapi/action.go b/x-pack/elastic-agent/pkg/fleetapi/action.go similarity index 97% rename from x-pack/agent/pkg/fleetapi/action.go rename to x-pack/elastic-agent/pkg/fleetapi/action.go index 1009531a451..bf59bc22e1a 100644 --- a/x-pack/agent/pkg/fleetapi/action.go +++ b/x-pack/elastic-agent/pkg/fleetapi/action.go @@ -9,7 +9,7 @@ import ( "fmt" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // Action base interface for all the implemented action from the fleet API. diff --git a/x-pack/agent/pkg/fleetapi/checkin_cmd.go b/x-pack/elastic-agent/pkg/fleetapi/checkin_cmd.go similarity index 97% rename from x-pack/agent/pkg/fleetapi/checkin_cmd.go rename to x-pack/elastic-agent/pkg/fleetapi/checkin_cmd.go index e0994d7a9de..80ce76d5b55 100644 --- a/x-pack/agent/pkg/fleetapi/checkin_cmd.go +++ b/x-pack/elastic-agent/pkg/fleetapi/checkin_cmd.go @@ -13,7 +13,7 @@ import ( "net/http" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) const checkingPath = "/api/ingest_manager/fleet/agents/%s/checkin" diff --git a/x-pack/agent/pkg/fleetapi/checkin_cmd_test.go b/x-pack/elastic-agent/pkg/fleetapi/checkin_cmd_test.go similarity index 100% rename from x-pack/agent/pkg/fleetapi/checkin_cmd_test.go rename to x-pack/elastic-agent/pkg/fleetapi/checkin_cmd_test.go diff --git a/x-pack/agent/pkg/fleetapi/client.go b/x-pack/elastic-agent/pkg/fleetapi/client.go similarity index 90% rename from x-pack/agent/pkg/fleetapi/client.go rename to x-pack/elastic-agent/pkg/fleetapi/client.go index d756c05c2d4..648620dcab9 100644 --- a/x-pack/agent/pkg/fleetapi/client.go +++ b/x-pack/elastic-agent/pkg/fleetapi/client.go @@ -14,11 +14,11 @@ import ( "net/url" "os" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "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/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) type clienter interface { diff --git a/x-pack/agent/pkg/fleetapi/client_test.go b/x-pack/elastic-agent/pkg/fleetapi/client_test.go similarity index 95% rename from x-pack/agent/pkg/fleetapi/client_test.go rename to x-pack/elastic-agent/pkg/fleetapi/client_test.go index e60496b8673..305bbafc117 100644 --- a/x-pack/agent/pkg/fleetapi/client_test.go +++ b/x-pack/elastic-agent/pkg/fleetapi/client_test.go @@ -16,10 +16,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" - "github.com/elastic/beats/v7/x-pack/agent/pkg/release" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func TestHTTPClient(t *testing.T) { diff --git a/x-pack/agent/pkg/fleetapi/custom_type.go b/x-pack/elastic-agent/pkg/fleetapi/custom_type.go similarity index 100% rename from x-pack/agent/pkg/fleetapi/custom_type.go rename to x-pack/elastic-agent/pkg/fleetapi/custom_type.go diff --git a/x-pack/agent/pkg/fleetapi/custom_type_test.go b/x-pack/elastic-agent/pkg/fleetapi/custom_type_test.go similarity index 100% rename from x-pack/agent/pkg/fleetapi/custom_type_test.go rename to x-pack/elastic-agent/pkg/fleetapi/custom_type_test.go diff --git a/x-pack/agent/pkg/fleetapi/enroll_cmd.go b/x-pack/elastic-agent/pkg/fleetapi/enroll_cmd.go similarity index 93% rename from x-pack/agent/pkg/fleetapi/enroll_cmd.go rename to x-pack/elastic-agent/pkg/fleetapi/enroll_cmd.go index 45ffde76c76..c7410baa0e7 100644 --- a/x-pack/agent/pkg/fleetapi/enroll_cmd.go +++ b/x-pack/elastic-agent/pkg/fleetapi/enroll_cmd.go @@ -14,10 +14,10 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) -// EnrollType is the type of enrollment to do with the agent. +// EnrollType is the type of enrollment to do with the elastic-agent. type EnrollType string const ( @@ -64,7 +64,7 @@ func (p EnrollType) MarshalJSON() ([]byte, error) { return json.Marshal(v) } -// EnrollRequest is the data required to enroll the agent into Fleet. +// EnrollRequest is the data required to enroll the elastic-agent into Fleet. // // Example: // POST /api/ingest_manager/fleet/agents/enroll @@ -82,7 +82,7 @@ type EnrollRequest struct { Metadata Metadata `json:"metadata"` } -// Metadata is a all the metadata send or received from the agent. +// Metadata is a all the metadata send or received from the elastic-agent. type Metadata struct { Local map[string]interface{} `json:"local"` UserProvided map[string]interface{} `json:"user_provided"` @@ -159,7 +159,7 @@ func (e *EnrollResponse) Validate() error { return err } -// EnrollCmd is the command to be executed to enroll an agent into Fleet. +// EnrollCmd is the command to be executed to enroll an elastic-agent into Fleet. type EnrollCmd struct { client clienter } diff --git a/x-pack/agent/pkg/fleetapi/enroll_cmd_test.go b/x-pack/elastic-agent/pkg/fleetapi/enroll_cmd_test.go similarity index 96% rename from x-pack/agent/pkg/fleetapi/enroll_cmd_test.go rename to x-pack/elastic-agent/pkg/fleetapi/enroll_cmd_test.go index ef46d8c89e0..c4f79c7cb38 100644 --- a/x-pack/agent/pkg/fleetapi/enroll_cmd_test.go +++ b/x-pack/elastic-agent/pkg/fleetapi/enroll_cmd_test.go @@ -14,8 +14,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" ) func TestEnroll(t *testing.T) { diff --git a/x-pack/agent/pkg/fleetapi/helper_test.go b/x-pack/elastic-agent/pkg/fleetapi/helper_test.go similarity index 91% rename from x-pack/agent/pkg/fleetapi/helper_test.go rename to x-pack/elastic-agent/pkg/fleetapi/helper_test.go index 3c5c5bbd4b8..89b9e913a47 100644 --- a/x-pack/agent/pkg/fleetapi/helper_test.go +++ b/x-pack/elastic-agent/pkg/fleetapi/helper_test.go @@ -13,8 +13,8 @@ import ( "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" ) func authHandler(handler http.HandlerFunc, apiKey string) http.HandlerFunc { diff --git a/x-pack/agent/pkg/fleetapi/round_trippers.go b/x-pack/elastic-agent/pkg/fleetapi/round_trippers.go similarity index 97% rename from x-pack/agent/pkg/fleetapi/round_trippers.go rename to x-pack/elastic-agent/pkg/fleetapi/round_trippers.go index de46b42426e..d163272e50d 100644 --- a/x-pack/agent/pkg/fleetapi/round_trippers.go +++ b/x-pack/elastic-agent/pkg/fleetapi/round_trippers.go @@ -8,7 +8,7 @@ import ( "errors" "net/http" - "github.com/elastic/beats/v7/x-pack/agent/pkg/kibana" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/kibana" ) // ErrInvalidAPIKey is returned when authentication fail to fleet. diff --git a/x-pack/agent/pkg/id/generate.go b/x-pack/elastic-agent/pkg/id/generate.go similarity index 100% rename from x-pack/agent/pkg/id/generate.go rename to x-pack/elastic-agent/pkg/id/generate.go diff --git a/x-pack/agent/pkg/id/generate_test.go b/x-pack/elastic-agent/pkg/id/generate_test.go similarity index 100% rename from x-pack/agent/pkg/id/generate_test.go rename to x-pack/elastic-agent/pkg/id/generate_test.go diff --git a/x-pack/agent/pkg/kibana/client.go b/x-pack/elastic-agent/pkg/kibana/client.go similarity index 97% rename from x-pack/agent/pkg/kibana/client.go rename to x-pack/elastic-agent/pkg/kibana/client.go index e8d588edb5b..9e7b7dfcd0d 100644 --- a/x-pack/agent/pkg/kibana/client.go +++ b/x-pack/elastic-agent/pkg/kibana/client.go @@ -17,8 +17,8 @@ import ( "github.com/elastic/beats/v7/libbeat/common" "github.com/elastic/beats/v7/libbeat/common/transport" "github.com/elastic/beats/v7/libbeat/common/transport/tlscommon" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) const kibanaPort = 5601 diff --git a/x-pack/agent/pkg/kibana/client_test.go b/x-pack/elastic-agent/pkg/kibana/client_test.go similarity index 98% rename from x-pack/agent/pkg/kibana/client_test.go rename to x-pack/elastic-agent/pkg/kibana/client_test.go index 51d29f29813..c750c889d81 100644 --- a/x-pack/agent/pkg/kibana/client_test.go +++ b/x-pack/elastic-agent/pkg/kibana/client_test.go @@ -18,8 +18,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/elastic/beats/v7/x-pack/agent/pkg/config" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/config" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) func noopWrapper(rt http.RoundTripper) (http.RoundTripper, error) { diff --git a/x-pack/agent/pkg/kibana/config.go b/x-pack/elastic-agent/pkg/kibana/config.go similarity index 100% rename from x-pack/agent/pkg/kibana/config.go rename to x-pack/elastic-agent/pkg/kibana/config.go diff --git a/x-pack/agent/pkg/kibana/round_trippers.go b/x-pack/elastic-agent/pkg/kibana/round_trippers.go similarity index 100% rename from x-pack/agent/pkg/kibana/round_trippers.go rename to x-pack/elastic-agent/pkg/kibana/round_trippers.go diff --git a/x-pack/agent/pkg/packer/packer.go b/x-pack/elastic-agent/pkg/packer/packer.go similarity index 97% rename from x-pack/agent/pkg/packer/packer.go rename to x-pack/elastic-agent/pkg/packer/packer.go index 7d62e6a024f..f6fa241f38d 100644 --- a/x-pack/agent/pkg/packer/packer.go +++ b/x-pack/elastic-agent/pkg/packer/packer.go @@ -14,7 +14,7 @@ import ( "path/filepath" "strings" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" ) // PackMap represents multiples files packed, the key represent the path of the file and raw bytes of diff --git a/x-pack/agent/pkg/packer/packer_test.go b/x-pack/elastic-agent/pkg/packer/packer_test.go similarity index 100% rename from x-pack/agent/pkg/packer/packer_test.go rename to x-pack/elastic-agent/pkg/packer/packer_test.go diff --git a/x-pack/agent/pkg/release/release_dev.go b/x-pack/elastic-agent/pkg/release/release_dev.go similarity index 100% rename from x-pack/agent/pkg/release/release_dev.go rename to x-pack/elastic-agent/pkg/release/release_dev.go diff --git a/x-pack/agent/pkg/release/version.go b/x-pack/elastic-agent/pkg/release/version.go similarity index 95% rename from x-pack/agent/pkg/release/version.go rename to x-pack/elastic-agent/pkg/release/version.go index 946e608c31e..fdb19bdf4f9 100644 --- a/x-pack/agent/pkg/release/version.go +++ b/x-pack/elastic-agent/pkg/release/version.go @@ -9,7 +9,7 @@ import ( "time" ) -// version is the current version of the agent. +// version is the current version of the elastic-agent. var version = "8.0.0" // buildHash is the hash of the current build. diff --git a/x-pack/agent/pkg/release/version_test.go b/x-pack/elastic-agent/pkg/release/version_test.go similarity index 100% rename from x-pack/agent/pkg/release/version_test.go rename to x-pack/elastic-agent/pkg/release/version_test.go diff --git a/x-pack/agent/pkg/reporter/backend.go b/x-pack/elastic-agent/pkg/reporter/backend.go similarity index 100% rename from x-pack/agent/pkg/reporter/backend.go rename to x-pack/elastic-agent/pkg/reporter/backend.go diff --git a/x-pack/agent/pkg/reporter/event.go b/x-pack/elastic-agent/pkg/reporter/event.go similarity index 100% rename from x-pack/agent/pkg/reporter/event.go rename to x-pack/elastic-agent/pkg/reporter/event.go diff --git a/x-pack/agent/pkg/reporter/fleet/config.go b/x-pack/elastic-agent/pkg/reporter/fleet/config.go similarity index 100% rename from x-pack/agent/pkg/reporter/fleet/config.go rename to x-pack/elastic-agent/pkg/reporter/fleet/config.go diff --git a/x-pack/agent/pkg/reporter/fleet/reporter.go b/x-pack/elastic-agent/pkg/reporter/fleet/reporter.go similarity index 95% rename from x-pack/agent/pkg/reporter/fleet/reporter.go rename to x-pack/elastic-agent/pkg/reporter/fleet/reporter.go index 7f8799b93c3..b4144a4da08 100644 --- a/x-pack/agent/pkg/reporter/fleet/reporter.go +++ b/x-pack/elastic-agent/pkg/reporter/fleet/reporter.go @@ -9,9 +9,9 @@ import ( "sync" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" ) const ( diff --git a/x-pack/agent/pkg/reporter/fleet/reporter_test.go b/x-pack/elastic-agent/pkg/reporter/fleet/reporter_test.go similarity index 97% rename from x-pack/agent/pkg/reporter/fleet/reporter_test.go rename to x-pack/elastic-agent/pkg/reporter/fleet/reporter_test.go index 61ed46c1169..d3a2d902a63 100644 --- a/x-pack/agent/pkg/reporter/fleet/reporter_test.go +++ b/x-pack/elastic-agent/pkg/reporter/fleet/reporter_test.go @@ -9,9 +9,9 @@ import ( "testing" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" - "github.com/elastic/beats/v7/x-pack/agent/pkg/fleetapi" - "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/fleetapi" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" ) func TestEventsHaveAgentID(t *testing.T) { diff --git a/x-pack/agent/pkg/reporter/log/config.go b/x-pack/elastic-agent/pkg/reporter/log/config.go similarity index 100% rename from x-pack/agent/pkg/reporter/log/config.go rename to x-pack/elastic-agent/pkg/reporter/log/config.go diff --git a/x-pack/agent/pkg/reporter/log/format.go b/x-pack/elastic-agent/pkg/reporter/log/format.go similarity index 100% rename from x-pack/agent/pkg/reporter/log/format.go rename to x-pack/elastic-agent/pkg/reporter/log/format.go diff --git a/x-pack/agent/pkg/reporter/log/reporter.go b/x-pack/elastic-agent/pkg/reporter/log/reporter.go similarity index 96% rename from x-pack/agent/pkg/reporter/log/reporter.go rename to x-pack/elastic-agent/pkg/reporter/log/reporter.go index 04fc28c394b..c57e46bd718 100644 --- a/x-pack/agent/pkg/reporter/log/reporter.go +++ b/x-pack/elastic-agent/pkg/reporter/log/reporter.go @@ -9,7 +9,7 @@ import ( "encoding/json" "fmt" - "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" ) type logger interface { diff --git a/x-pack/agent/pkg/reporter/log/reporter_test.go b/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go similarity index 97% rename from x-pack/agent/pkg/reporter/log/reporter_test.go rename to x-pack/elastic-agent/pkg/reporter/log/reporter_test.go index a551809f0f7..cf361e1395e 100644 --- a/x-pack/agent/pkg/reporter/log/reporter_test.go +++ b/x-pack/elastic-agent/pkg/reporter/log/reporter_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" ) type testCase struct { diff --git a/x-pack/agent/pkg/reporter/noop/reporter.go b/x-pack/elastic-agent/pkg/reporter/noop/reporter.go similarity index 92% rename from x-pack/agent/pkg/reporter/noop/reporter.go rename to x-pack/elastic-agent/pkg/reporter/noop/reporter.go index 6412c9ff162..01e10fb4184 100644 --- a/x-pack/agent/pkg/reporter/noop/reporter.go +++ b/x-pack/elastic-agent/pkg/reporter/noop/reporter.go @@ -7,7 +7,7 @@ package noop import ( "context" - "github.com/elastic/beats/v7/x-pack/agent/pkg/reporter" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/reporter" ) // Reporter is a reporter without any effects, serves just as a showcase for further implementations. diff --git a/x-pack/agent/pkg/reporter/reporter.go b/x-pack/elastic-agent/pkg/reporter/reporter.go similarity index 96% rename from x-pack/agent/pkg/reporter/reporter.go rename to x-pack/elastic-agent/pkg/reporter/reporter.go index 74bea56a760..d10cb5ece05 100644 --- a/x-pack/agent/pkg/reporter/reporter.go +++ b/x-pack/elastic-agent/pkg/reporter/reporter.go @@ -11,8 +11,8 @@ import ( "github.com/hashicorp/go-multierror" - "github.com/elastic/beats/v7/x-pack/agent/pkg/agent/errors" - "github.com/elastic/beats/v7/x-pack/agent/pkg/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/agent/errors" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/logger" ) const ( diff --git a/x-pack/agent/pkg/reporter/reporter_test.go b/x-pack/elastic-agent/pkg/reporter/reporter_test.go similarity index 100% rename from x-pack/agent/pkg/reporter/reporter_test.go rename to x-pack/elastic-agent/pkg/reporter/reporter_test.go diff --git a/x-pack/agent/pkg/scheduler/scheduler.go b/x-pack/elastic-agent/pkg/scheduler/scheduler.go similarity index 100% rename from x-pack/agent/pkg/scheduler/scheduler.go rename to x-pack/elastic-agent/pkg/scheduler/scheduler.go diff --git a/x-pack/agent/pkg/scheduler/scheduler_test.go b/x-pack/elastic-agent/pkg/scheduler/scheduler_test.go similarity index 100% rename from x-pack/agent/pkg/scheduler/scheduler_test.go rename to x-pack/elastic-agent/pkg/scheduler/scheduler_test.go diff --git a/x-pack/agent/pkg/sorted/set.go b/x-pack/elastic-agent/pkg/sorted/set.go similarity index 100% rename from x-pack/agent/pkg/sorted/set.go rename to x-pack/elastic-agent/pkg/sorted/set.go diff --git a/x-pack/agent/pkg/sorted/set_test.go b/x-pack/elastic-agent/pkg/sorted/set_test.go similarity index 100% rename from x-pack/agent/pkg/sorted/set_test.go rename to x-pack/elastic-agent/pkg/sorted/set_test.go diff --git a/x-pack/agent/pkg/tokenbucket/token_bucket.go b/x-pack/elastic-agent/pkg/tokenbucket/token_bucket.go similarity index 96% rename from x-pack/agent/pkg/tokenbucket/token_bucket.go rename to x-pack/elastic-agent/pkg/tokenbucket/token_bucket.go index 2caba44ddb2..681fffdc470 100644 --- a/x-pack/agent/pkg/tokenbucket/token_bucket.go +++ b/x-pack/elastic-agent/pkg/tokenbucket/token_bucket.go @@ -8,7 +8,7 @@ import ( "fmt" "time" - "github.com/elastic/beats/v7/x-pack/agent/pkg/scheduler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler" ) // Bucket is a Token Bucket for rate limiting diff --git a/x-pack/agent/pkg/tokenbucket/token_bucket_test.go b/x-pack/elastic-agent/pkg/tokenbucket/token_bucket_test.go similarity index 97% rename from x-pack/agent/pkg/tokenbucket/token_bucket_test.go rename to x-pack/elastic-agent/pkg/tokenbucket/token_bucket_test.go index f1ad6c452a0..8c87d946047 100644 --- a/x-pack/agent/pkg/tokenbucket/token_bucket_test.go +++ b/x-pack/elastic-agent/pkg/tokenbucket/token_bucket_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/elastic/beats/v7/x-pack/agent/pkg/scheduler" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/scheduler" ) func TestTokenBucket(t *testing.T) { diff --git a/x-pack/agent/proto/remote_config.proto b/x-pack/elastic-agent/proto/remote_config.proto similarity index 100% rename from x-pack/agent/proto/remote_config.proto rename to x-pack/elastic-agent/proto/remote_config.proto diff --git a/x-pack/agent/spec/auditbeat.yml.disabled b/x-pack/elastic-agent/spec/auditbeat.yml.disabled similarity index 100% rename from x-pack/agent/spec/auditbeat.yml.disabled rename to x-pack/elastic-agent/spec/auditbeat.yml.disabled diff --git a/x-pack/agent/spec/filebeat.yml b/x-pack/elastic-agent/spec/filebeat.yml similarity index 88% rename from x-pack/agent/spec/filebeat.yml rename to x-pack/elastic-agent/spec/filebeat.yml index 7b0858f5428..a5cda0c2382 100644 --- a/x-pack/agent/spec/filebeat.yml +++ b/x-pack/elastic-agent/spec/filebeat.yml @@ -14,12 +14,10 @@ rules: - map: path: inputsstreams rules: - - copy_to_list: - item: type - to: streams - - copy_to_list: - item: processors + - copy_all_to_list: to: streams + overwrite: false + except: ["streams", "id", "enabled", "title", "package", "namespace", "constraints", "use_output"] - extract_list_items: path: inputsstreams diff --git a/x-pack/agent/spec/heartbeat.yml.disabled b/x-pack/elastic-agent/spec/heartbeat.yml.disabled similarity index 100% rename from x-pack/agent/spec/heartbeat.yml.disabled rename to x-pack/elastic-agent/spec/heartbeat.yml.disabled diff --git a/x-pack/agent/spec/journalbeat.yml.disabled b/x-pack/elastic-agent/spec/journalbeat.yml.disabled similarity index 100% rename from x-pack/agent/spec/journalbeat.yml.disabled rename to x-pack/elastic-agent/spec/journalbeat.yml.disabled diff --git a/x-pack/agent/spec/metricbeat.yml b/x-pack/elastic-agent/spec/metricbeat.yml similarity index 93% rename from x-pack/agent/spec/metricbeat.yml rename to x-pack/elastic-agent/spec/metricbeat.yml index 390749a3327..515b23f3035 100644 --- a/x-pack/agent/spec/metricbeat.yml +++ b/x-pack/elastic-agent/spec/metricbeat.yml @@ -18,12 +18,10 @@ rules: - map: path: inputsstreams rules: - - copy_to_list: - item: type - to: streams - - copy_to_list: - item: processors + - copy_all_to_list: to: streams + overwrite: false + except: ["streams", "id", "enabled"] - extract_list_items: path: inputsstreams diff --git a/x-pack/libbeat/management/config.go b/x-pack/libbeat/management/config.go index 7ff40a6a541..1e332c38ab9 100644 --- a/x-pack/libbeat/management/config.go +++ b/x-pack/libbeat/management/config.go @@ -68,11 +68,23 @@ const ManagedConfigTemplate = ` #monitoring.elasticsearch: ` -// Config for central management +const ( + // ModeCentralManagement is a default CM mode, using existing processes. + ModeCentralManagement = "x-pack-cm" + + // ModeFleet is a management mode where fleet is used to retrieve configurations. + ModeFleet = "x-pack-fleet" +) + +// Config for central management. type Config struct { // true when enrolled Enabled bool `config:"enabled" yaml:"enabled"` + // Mode specifies whether beat uses Central Management or Fleet. + // Options: [cm, fleet] + Mode string `config:"mode" yaml:"mode"` + // Poll configs period Period time.Duration `config:"period" yaml:"period"` @@ -93,6 +105,7 @@ type EventReporterConfig struct { func defaultConfig() *Config { return &Config{ + Mode: ModeCentralManagement, Period: 60 * time.Second, EventsReporter: EventReporterConfig{ Period: 30 * time.Second, @@ -111,7 +124,7 @@ type templateParams struct { BeatName string } -// OverwriteConfigFile will overwrite beat settings file with the enrolled template +// OverwriteConfigFile will overwrite beat settings file with the enrolled template. func (c *Config) OverwriteConfigFile(wr io.Writer, beatName string) error { t := template.Must(template.New("beat.management.yml").Parse(ManagedConfigTemplate)) diff --git a/x-pack/libbeat/management/error.go b/x-pack/libbeat/management/error.go index ab320159396..31fd8df3d08 100644 --- a/x-pack/libbeat/management/error.go +++ b/x-pack/libbeat/management/error.go @@ -103,6 +103,7 @@ func (er *Errors) IsEmpty() bool { return len(*er) == 0 } -func newConfigError(err error) *Error { +// NewConfigError wraps an error to be a management error of a specific ConfigError Type +func NewConfigError(err error) *Error { return &Error{Type: ConfigError, Err: err} } diff --git a/x-pack/libbeat/management/error_test.go b/x-pack/libbeat/management/error_test.go index 1416199c019..4d29d3aacad 100644 --- a/x-pack/libbeat/management/error_test.go +++ b/x-pack/libbeat/management/error_test.go @@ -54,14 +54,14 @@ func TestErrorSerialization(t *testing.T) { func TestErrors(t *testing.T) { t.Run("single error", func(t *testing.T) { - errors := Errors{newConfigError(errors.New("error1"))} + errors := Errors{NewConfigError(errors.New("error1"))} assert.Equal(t, "1 error: error1", errors.Error()) }) t.Run("multiple errors", func(t *testing.T) { errors := Errors{ - newConfigError(errors.New("error1")), - newConfigError(errors.New("error2")), + NewConfigError(errors.New("error1")), + NewConfigError(errors.New("error2")), } assert.Equal(t, "2 errors: error1; error2", errors.Error()) }) diff --git a/x-pack/libbeat/management/fleet/config.go b/x-pack/libbeat/management/fleet/config.go new file mode 100644 index 00000000000..9572d30acc9 --- /dev/null +++ b/x-pack/libbeat/management/fleet/config.go @@ -0,0 +1,27 @@ +// 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 fleet + +import ( + xmanagement "github.com/elastic/beats/v7/x-pack/libbeat/management" +) + +// Config for central management +type Config struct { + Enabled bool `config:"enabled" yaml:"enabled"` + Mode string `config:"mode" yaml:"mode"` + Blacklist xmanagement.ConfigBlacklistSettings `config:"blacklist" yaml:"blacklist"` +} + +func defaultConfig() *Config { + return &Config{ + Mode: xmanagement.ModeCentralManagement, + Blacklist: xmanagement.ConfigBlacklistSettings{ + Patterns: map[string]string{ + "output": "console|file", + }, + }, + } +} diff --git a/x-pack/libbeat/management/fleet/config_server.go b/x-pack/libbeat/management/fleet/config_server.go new file mode 100644 index 00000000000..5a74d50c981 --- /dev/null +++ b/x-pack/libbeat/management/fleet/config_server.go @@ -0,0 +1,61 @@ +// 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 fleet + +import ( + "context" + "errors" + "fmt" + "time" + + "github.com/elastic/beats/v7/libbeat/common" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/remoteconfig/grpc" +) + +const ( + defaultTimeout = 15 * time.Second +) + +// Server is a server for handling communication between +// beat and Elastic Agent. +type Server struct { + configChan chan<- map[string]interface{} +} + +// NewConfigServer creates a new grpc configuration server for receiving +// configurations from Elastic Agent. +func NewConfigServer(configChan chan<- map[string]interface{}) *Server { + return &Server{ + configChan: configChan, + } +} + +// Config is a handler of a call made by agent pushing latest configuration. +func (s *Server) Config(ctx context.Context, req *grpc.ConfigRequest) (*grpc.ConfigResponse, error) { + cfgString := req.GetConfig() + + var configMap common.MapStr + uconfig, err := common.NewConfigFrom(cfgString) + if err != nil { + return &grpc.ConfigResponse{}, fmt.Errorf("config blocks unsuccessfully generated: %+v", err) + } + + err = uconfig.Unpack(&configMap) + if err != nil { + return &grpc.ConfigResponse{}, fmt.Errorf("config blocks unsuccessfully generated: %+v", err) + } + + select { + case s.configChan <- configMap: + case <-time.After(defaultTimeout): + return &grpc.ConfigResponse{}, errors.New("failed to push configuration: Timeout") + } + return &grpc.ConfigResponse{}, nil +} + +// Status returns OK. +func (s *Server) Status(ctx context.Context, req *grpc.StatusRequest) (*grpc.StatusResponse, error) { + return &grpc.StatusResponse{Status: "ok"}, nil +} diff --git a/x-pack/libbeat/management/fleet/manager.go b/x-pack/libbeat/management/fleet/manager.go new file mode 100644 index 00000000000..483b697eda3 --- /dev/null +++ b/x-pack/libbeat/management/fleet/manager.go @@ -0,0 +1,279 @@ +// 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 fleet + +import ( + "fmt" + "os" + "sort" + "sync" + + "github.com/gofrs/uuid" + "github.com/pkg/errors" + + "github.com/elastic/beats/v7/libbeat/common" + "github.com/elastic/beats/v7/libbeat/common/cfgwarn" + "github.com/elastic/beats/v7/libbeat/common/reload" + "github.com/elastic/beats/v7/libbeat/logp" + "github.com/elastic/beats/v7/libbeat/management" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/core/plugin/server" + "github.com/elastic/beats/v7/x-pack/libbeat/management/api" + + xmanagement "github.com/elastic/beats/v7/x-pack/libbeat/management" +) + +// ConfigManager provides a functionality to retrieve config channel +// using which manager is informed about config changes. +type ConfigManager interface { + ConfigChan() chan<- map[string]interface{} +} + +// Manager handles internal config updates. By retrieving +// new configs from Kibana and applying them to the Beat. +type Manager struct { + config *Config + logger *logp.Logger + beatUUID uuid.UUID + done chan struct{} + registry *reload.Registry + wg sync.WaitGroup + blacklist *xmanagement.ConfigBlacklist + + configChan chan map[string]interface{} +} + +// NewFleetManager returns a X-Pack Beats Fleet Management manager. +func NewFleetManager(config *common.Config, registry *reload.Registry, beatUUID uuid.UUID) (management.ConfigManager, error) { + c := defaultConfig() + if config.Enabled() { + if err := config.Unpack(&c); err != nil { + return nil, errors.Wrap(err, "parsing fleet management settings") + } + } + return NewFleetManagerWithConfig(c, registry, beatUUID) +} + +// NewFleetManagerWithConfig returns a X-Pack Beats Fleet Management manager. +func NewFleetManagerWithConfig(c *Config, registry *reload.Registry, beatUUID uuid.UUID) (management.ConfigManager, error) { + var blacklist *xmanagement.ConfigBlacklist + + if c.Enabled && c.Mode == xmanagement.ModeFleet { + var err error + + // Initialize configs blacklist + blacklist, err = xmanagement.NewConfigBlacklist(c.Blacklist) + if err != nil { + return nil, errors.Wrap(err, "wrong settings for configurations blacklist") + } + } + + log := logp.NewLogger(management.DebugK) + + m := &Manager{ + config: c, + blacklist: blacklist, + logger: log.Named("fleet"), + done: make(chan struct{}), + beatUUID: beatUUID, + registry: registry, + configChan: make(chan map[string]interface{}), + } + + go m.startGrpcServer() + + return m, nil +} + +// Enabled returns true if config management is enabled. +func (cm *Manager) Enabled() bool { + return cm.config.Enabled && cm.config.Mode == xmanagement.ModeFleet +} + +// ConfigChan returns a channel used to communicate configuration changes. +func (cm *Manager) ConfigChan() chan<- map[string]interface{} { + return cm.configChan +} + +// Start the config manager +func (cm *Manager) Start() { + if !cm.Enabled() { + return + } + + cfgwarn.Beta("Fleet management is enabled") + cm.logger.Info("Starting fleet management service") + + cm.wg.Add(1) + go cm.worker() +} + +// Stop the config manager +func (cm *Manager) Stop() { + if !cm.Enabled() { + return + } + + // stop collecting configuration + cm.logger.Info("Stopping fleet management service") + close(cm.done) + cm.wg.Wait() +} + +// CheckRawConfig check settings are correct to start the beat. This method +// checks there are no collision between the existing configuration and what +// fleet management can configure. +func (cm *Manager) CheckRawConfig(cfg *common.Config) error { + // TODO implement this method + return nil +} + +func (cm *Manager) worker() { + defer cm.wg.Done() + + // Start worker loop: fetch + apply new settings +WORKERLOOP: + for { + select { + case cfg := <-cm.configChan: + blocks, err := cm.toConfigBlocks(cfg) + if err != nil { + cm.logger.Errorf("Could not apply the configuration, error: %+v", err) + continue WORKERLOOP + } + + if errs := cm.apply(blocks); !errs.IsEmpty() { + cm.logger.Errorf("Could not apply the configuration, error: %+v", errs) + continue WORKERLOOP + } + case <-cm.done: + return + } + } +} + +func (cm *Manager) apply(blocks api.ConfigBlocks) xmanagement.Errors { + var errors xmanagement.Errors + missing := map[string]bool{} + for _, name := range cm.registry.GetRegisteredNames() { + missing[name] = true + } + + // Detect unwanted configs from the list + if errs := cm.blacklist.Detect(blocks); !errs.IsEmpty() { + errors = append(errors, errs...) + return errors + } + + // Reload configs + for _, b := range blocks { + if err := cm.reload(b.Type, b.Blocks); err != nil { + errors = append(errors, err) + } + missing[b.Type] = false + } + + // Unset missing configs + for name := range missing { + if missing[name] { + if err := cm.reload(name, []*api.ConfigBlock{}); err != nil { + errors = append(errors, err) + } + } + } + + return errors +} + +func (cm *Manager) reload(t string, blocks []*api.ConfigBlock) *xmanagement.Error { + cm.logger.Infof("Applying settings for %s", t) + if obj := cm.registry.GetReloadable(t); obj != nil { + // Single object + if len(blocks) > 1 { + err := fmt.Errorf("got an invalid number of configs for %s: %d, expected: 1", t, len(blocks)) + cm.logger.Error(err) + return xmanagement.NewConfigError(err) + } + + var config *reload.ConfigWithMeta + var err error + if len(blocks) == 1 { + config, err = blocks[0].ConfigWithMeta() + if err != nil { + cm.logger.Error(err) + return xmanagement.NewConfigError(err) + } + } + + if err := obj.Reload(config); err != nil { + cm.logger.Error(err) + return xmanagement.NewConfigError(err) + } + } else if obj := cm.registry.GetReloadableList(t); obj != nil { + // List + var configs []*reload.ConfigWithMeta + for _, block := range blocks { + config, err := block.ConfigWithMeta() + if err != nil { + cm.logger.Error(err) + return xmanagement.NewConfigError(err) + } + configs = append(configs, config) + } + + if err := obj.Reload(configs); err != nil { + cm.logger.Error(err) + return xmanagement.NewConfigError(err) + } + } + + return nil +} + +func (cm *Manager) toConfigBlocks(cfg common.MapStr) (api.ConfigBlocks, error) { + blocks := map[string][]*api.ConfigBlock{} + + // Extract all registered values beat can respond to + for _, regName := range cm.registry.GetRegisteredNames() { + iBlock, err := cfg.GetValue(regName) + if err != nil { + continue + } + + if mapBlock, ok := iBlock.(map[string]interface{}); ok { + blocks[regName] = append(blocks[regName], &api.ConfigBlock{Raw: mapBlock}) + } else if arrayBlock, ok := iBlock.([]interface{}); ok { + for _, item := range arrayBlock { + if mapBlock, ok := item.(map[string]interface{}); ok { + blocks[regName] = append(blocks[regName], &api.ConfigBlock{Raw: mapBlock}) + } + } + } + } + + // keep the ordering consistent while grouping the items. + keys := make([]string, 0, len(blocks)) + for k := range blocks { + keys = append(keys, k) + } + sort.Strings(keys) + + res := api.ConfigBlocks{} + for _, t := range keys { + b := blocks[t] + res = append(res, api.ConfigBlocksWithType{Type: t, Blocks: b}) + } + + return res, nil +} + +func (cm *Manager) startGrpcServer() { + cm.logger.Info("initiating fleet config manager") + s := NewConfigServer(cm.ConfigChan()) + if err := server.NewGrpcServer(os.Stdin, s); err != nil { + panic(err) + } +} + +var _ ConfigManager = &Manager{} diff --git a/x-pack/libbeat/management/fleet/manager_test.go b/x-pack/libbeat/management/fleet/manager_test.go new file mode 100644 index 00000000000..7af72a04291 --- /dev/null +++ b/x-pack/libbeat/management/fleet/manager_test.go @@ -0,0 +1,60 @@ +// 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 fleet + +import ( + "testing" + + "github.com/elastic/beats/v7/libbeat/common" + + "github.com/elastic/beats/v7/libbeat/common/reload" +) + +func TestConfigBlocks(t *testing.T) { + input := ` +filebeat: + inputs: + - type: log + paths: + - /var/log/hello1.log + - /var/log/hello2.log +output: + elasticsearch: + hosts: + - localhost:9200` + + var cfg common.MapStr + uconfig, err := common.NewConfigFrom(input) + if err != nil { + t.Fatalf("Config blocks unsuccessfully generated: %+v", err) + } + + err = uconfig.Unpack(&cfg) + if err != nil { + t.Fatalf("Config blocks unsuccessfully generated: %+v", err) + } + + reg := reload.NewRegistry() + reg.Register("output", &dummyReloadable{}) + reg.Register("filebeat.inputs", &dummyReloadable{}) + + cm := &Manager{ + registry: reg, + } + blocks, err := cm.toConfigBlocks(cfg) + if err != nil { + t.Fatalf("Config blocks unsuccessfully generated: %+v", err) + } + + if len(blocks) != 2 { + t.Fatalf("Expected 2 block have %d: %+v", len(blocks), blocks) + } +} + +type dummyReloadable struct{} + +func (dummyReloadable) Reload(config *reload.ConfigWithMeta) error { + return nil +} diff --git a/x-pack/libbeat/management/fleet/plugin.go b/x-pack/libbeat/management/fleet/plugin.go new file mode 100644 index 00000000000..edb12ca78f1 --- /dev/null +++ b/x-pack/libbeat/management/fleet/plugin.go @@ -0,0 +1,32 @@ +// 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 fleet + +import ( + "github.com/elastic/beats/v7/libbeat/common" + "github.com/elastic/beats/v7/libbeat/feature" + "github.com/elastic/beats/v7/libbeat/management" + xmanagement "github.com/elastic/beats/v7/x-pack/libbeat/management" +) + +func init() { + management.Register("x-pack-fleet", NewFleetManagerPlugin, feature.Beta) +} + +// NewFleetManagerPlugin creates a plugin function returning factory if configuration matches the criteria +func NewFleetManagerPlugin(config *common.Config) management.FactoryFunc { + c := defaultConfig() + if config.Enabled() { + if err := config.Unpack(&c); err != nil { + return nil + } + + if c.Mode == xmanagement.ModeFleet { + return NewFleetManager + } + } + + return nil +} diff --git a/x-pack/libbeat/management/manager.go b/x-pack/libbeat/management/manager.go index 66fdabe9d99..74770ef424a 100644 --- a/x-pack/libbeat/management/manager.go +++ b/x-pack/libbeat/management/manager.go @@ -10,7 +10,6 @@ import ( "time" "github.com/elastic/beats/v7/libbeat/common/reload" - "github.com/elastic/beats/v7/libbeat/feature" "github.com/gofrs/uuid" @@ -26,10 +25,6 @@ import ( var errEmptyAccessToken = errors.New("access_token is empty, you must reenroll your Beat") -func init() { - management.Register("x-pack", NewConfigManager, feature.Beta) -} - // ConfigManager handles internal config updates. By retrieving // new configs from Kibana and applying them to the Beat type ConfigManager struct { @@ -284,7 +279,7 @@ func (cm *ConfigManager) reload(t string, blocks []*api.ConfigBlock) *Error { if len(blocks) > 1 { err := fmt.Errorf("got an invalid number of configs for %s: %d, expected: 1", t, len(blocks)) cm.logger.Error(err) - return newConfigError(err) + return NewConfigError(err) } var config *reload.ConfigWithMeta @@ -293,13 +288,13 @@ func (cm *ConfigManager) reload(t string, blocks []*api.ConfigBlock) *Error { config, err = blocks[0].ConfigWithMeta() if err != nil { cm.logger.Error(err) - return newConfigError(err) + return NewConfigError(err) } } if err := obj.Reload(config); err != nil { cm.logger.Error(err) - return newConfigError(err) + return NewConfigError(err) } } else if obj := cm.registry.GetReloadableList(t); obj != nil { // List @@ -308,14 +303,14 @@ func (cm *ConfigManager) reload(t string, blocks []*api.ConfigBlock) *Error { config, err := block.ConfigWithMeta() if err != nil { cm.logger.Error(err) - return newConfigError(err) + return NewConfigError(err) } configs = append(configs, config) } if err := obj.Reload(configs); err != nil { cm.logger.Error(err) - return newConfigError(err) + return NewConfigError(err) } } diff --git a/x-pack/libbeat/management/manager_test.go b/x-pack/libbeat/management/manager_test.go index 90370286d14..af0c8816ebe 100644 --- a/x-pack/libbeat/management/manager_test.go +++ b/x-pack/libbeat/management/manager_test.go @@ -73,6 +73,7 @@ func TestConfigManager(t *testing.T) { config := &Config{ Enabled: true, + Mode: ModeCentralManagement, Period: 100 * time.Millisecond, Kibana: c, AccessToken: accessToken, @@ -148,6 +149,7 @@ func TestRemoveItems(t *testing.T) { config := &Config{ Enabled: true, + Mode: ModeCentralManagement, Period: 100 * time.Millisecond, Kibana: c, AccessToken: accessToken, @@ -225,6 +227,7 @@ func TestUnEnroll(t *testing.T) { config := &Config{ Enabled: true, + Mode: ModeCentralManagement, Period: 100 * time.Millisecond, Kibana: c, AccessToken: accessToken, @@ -299,6 +302,7 @@ func TestBadConfig(t *testing.T) { config := &Config{ Enabled: true, + Mode: ModeCentralManagement, Period: 100 * time.Millisecond, Kibana: c, AccessToken: accessToken, diff --git a/x-pack/libbeat/management/plugin.go b/x-pack/libbeat/management/plugin.go new file mode 100644 index 00000000000..b1e7b7d13b9 --- /dev/null +++ b/x-pack/libbeat/management/plugin.go @@ -0,0 +1,31 @@ +// 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 management + +import ( + "github.com/elastic/beats/v7/libbeat/common" + "github.com/elastic/beats/v7/libbeat/feature" + "github.com/elastic/beats/v7/libbeat/management" +) + +func init() { + management.Register("x-pack", NewManagerPlugin, feature.Beta) +} + +// NewManagerPlugin creates a plugin function returning factory if configuration matches the criteria +func NewManagerPlugin(config *common.Config) management.FactoryFunc { + c := defaultConfig() + if config.Enabled() { + if err := config.Unpack(&c); err != nil { + return nil + } + + if c.Mode == ModeCentralManagement { + return NewConfigManager + } + } + + return nil +}