From dcee41206fb545db6a38f285ba2741380d3fc940 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Thu, 24 Sep 2020 10:42:53 +0200 Subject: [PATCH] [Ingest Manager] Enabled dev builds (#21241) [Ingest Manager] Enabled dev builds (#21241) --- x-pack/elastic-agent/magefile.go | 23 +++++++++++++++++++++++ x-pack/elastic-agent/pkg/agent/cmd/run.go | 5 +++++ 2 files changed, 28 insertions(+) diff --git a/x-pack/elastic-agent/magefile.go b/x-pack/elastic-agent/magefile.go index ec6e76a0995..a4a5f314869 100644 --- a/x-pack/elastic-agent/magefile.go +++ b/x-pack/elastic-agent/magefile.go @@ -81,6 +81,9 @@ type Format mg.Namespace // Demo runs agent out of container. type Demo mg.Namespace +// Dev runs package and build for dev purposes. +type Dev mg.Namespace + // Env returns information about the environment. func (Prepare) Env() { mg.Deps(Mkdir("build"), Build.GenerateConfig) @@ -88,6 +91,26 @@ func (Prepare) Env() { RunGo("env") } +// Build builds the agent binary with DEV flag set. +func (Dev) Build() { + dev := os.Getenv(devEnv) + defer os.Setenv(devEnv, dev) + + os.Setenv(devEnv, "true") + devtools.DevBuild = true + mg.Deps(Build.All) +} + +// Package packages the agent binary with DEV flag set. +func (Dev) Package() { + dev := os.Getenv(devEnv) + defer os.Setenv(devEnv, dev) + + os.Setenv(devEnv, "true") + devtools.DevBuild = true + Package() +} + // InstallGoLicenser install go-licenser to check license of the files. func (Prepare) InstallGoLicenser() error { return GoGet(goLicenserRepo) diff --git a/x-pack/elastic-agent/pkg/agent/cmd/run.go b/x-pack/elastic-agent/pkg/agent/cmd/run.go index a7b56a664ba..77beeb6fe1a 100644 --- a/x-pack/elastic-agent/pkg/agent/cmd/run.go +++ b/x-pack/elastic-agent/pkg/agent/cmd/run.go @@ -23,6 +23,7 @@ import ( "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/core/logger" + "github.com/elastic/beats/v7/x-pack/elastic-agent/pkg/release" ) func newRunCommandWithArgs(flags *globalFlags, _ []string, streams *cli.IOStreams) *cobra.Command { @@ -82,6 +83,10 @@ func run(flags *globalFlags, streams *cli.IOStreams) error { // Windows: Mark se return err } + if allowEmptyPgp, _ := release.PGP(); allowEmptyPgp { + logger.Warn("Artifact has been build with security disabled. Elastic Agent will not verify signatures of used artifacts.") + } + execPath, err := os.Executable() if err != nil { return err