Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .ci/scripts/update-otel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ next_stable_core=${2:-}

next_contrib=${3:-$next_beta_core}

# Get current versions from go.mod
current_beta_core=$(grep 'go\.opentelemetry\.io/collector/receiver/otlpreceiver ' go.mod | cut -d' ' -f 2 || true)
current_stable_core=$(grep 'go\.opentelemetry\.io/collector/confmap/provider/fileprovider ' go.mod | cut -d' ' -f 2 || true)
current_contrib=$(grep 'github\.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver ' go.mod | cut -d' ' -f 2 || true)
# Get current versions from internal/edot/go.mod
current_beta_core=$(grep 'go\.opentelemetry\.io/collector/receiver/otlpreceiver ' internal/edot/go.mod | cut -d' ' -f 2 || true)
current_stable_core=$(grep 'go\.opentelemetry\.io/collector/confmap/provider/fileprovider ' internal/edot/go.mod | cut -d' ' -f 2 || true)
current_contrib=$(grep 'github\.com/open-telemetry/opentelemetry-collector-contrib/receiver/filelogreceiver ' internal/edot/go.mod | cut -d' ' -f 2 || true)

[[ -n "$current_beta_core" ]] || (echo "Error: couldn't find current beta core version." && exit 2)
[[ -n "$current_stable_core" ]] || (echo "Error: couldn't find current stable core version" && exit 3)
Expand All @@ -30,10 +30,10 @@ current_contrib=$(grep 'github\.com/open-telemetry/opentelemetry-collector-contr
echo "=> Updating core from $current_beta_core/$current_stable_core to $next_beta_core/$next_stable_core"
echo "=> Updating contrib from $current_contrib to $next_contrib"

sed -i.bak "s/\(go\.opentelemetry\.io\/collector.*\) $current_beta_core/\1 $next_beta_core/" go.mod
sed -i.bak "s/\(go\.opentelemetry\.io\/collector.*\) $current_stable_core/\1 $next_stable_core/" go.mod
sed -i.bak "s/\(github\.com\/open-telemetry\/opentelemetry\-collector\-contrib\/.*\) $current_contrib/\1 $next_contrib/" go.mod
rm go.mod.bak
sed -i.bak "s/\(go\.opentelemetry\.io\/collector.*\) $current_beta_core/\1 $next_beta_core/" internal/edot/go.mod
sed -i.bak "s/\(go\.opentelemetry\.io\/collector.*\) $current_stable_core/\1 $next_stable_core/" internal/edot/go.mod
sed -i.bak "s/\(github\.com\/open-telemetry\/opentelemetry\-collector\-contrib\/.*\) $current_contrib/\1 $next_contrib/" internal/edot/go.mod
rm internal/edot/go.mod.bak

echo "=> Running go mod tidy"
go mod tidy
Expand Down
9 changes: 9 additions & 0 deletions .ci/updatecli/updatecli-bump-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ targets:
content: 'go {{ source "latestGoVersion" }}'
file: wrapper/windows/archive-proxy/go.mod
matchpattern: 'go \d+.\d+.\d+'
update-edot-gomod-full-version:
name: "Update internal/edot/go.mod version"
sourceid: latestGoVersion
scmid: githubConfig
kind: file
spec:
content: 'go {{ source "latestGoVersion" }}'
file: internal/edot/go.mod
matchpattern: 'go \d+.\d+.\d+'
update-buildkite-pipeline:
name: "Update .buildkite/pipeline.yml"
sourceid: latestGoVersion
Expand Down
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ linters:
- github.com/insomniacslk/dhcp
- github.com/meraki/dashboard-api-go/v3
- go.opentelemetry.io/otel/exporters/prometheus
replace-local: false
- github.com/elastic/elastic-agent/internal/edot
replace-local: true
gomodguard:
blocked:
modules:
Expand Down
48,403 changes: 24,147 additions & 24,256 deletions NOTICE-fips.txt

Large diffs are not rendered by default.

51,637 changes: 25,870 additions & 25,767 deletions NOTICE.txt

Large diffs are not rendered by default.

56 changes: 54 additions & 2 deletions dev-tools/mage/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import (
"errors"
"fmt"
"go/build"
"io"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"

"github.com/josephspurrier/goversioninfo"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
"golang.org/x/text/cases"
"golang.org/x/text/language"
Expand All @@ -35,6 +38,8 @@ type BuildArgs struct {
Vars map[string]string // Vars that are passed as -X key=value with the ldflags.
ExtraFlags []string
WinMetadata bool // Add resource metadata to Windows binaries (like add the version number to the .exe properties).
Package string
WorkDir string
}

// buildTagRE is a regexp to match strings like "-tags=abcd"
Expand Down Expand Up @@ -205,10 +210,14 @@ func Build(params BuildArgs) error {
env["CGO_ENABLED"] = cgoEnabled

// Spec
outputDir, err := filepath.Abs(filepath.Join(params.OutputDir, binaryName))
if err != nil {
return fmt.Errorf("failed getting absolute path for %v: %w", params.OutputDir, err)
}
args := []string{
"build",
"-o",
filepath.Join(params.OutputDir, binaryName),
outputDir,
}
args = append(args, params.ParseBuildTags()...)

Expand Down Expand Up @@ -238,8 +247,51 @@ func Build(params BuildArgs) error {
defer os.Remove(syso)
}

if params.Package != "" {
args = append(args, params.Package)
}

log.Println("Adding build environment vars:", env)
return sh.RunWith(env, "go", args...)
var output io.Writer
if mg.Verbose() {
output = os.Stdout
}
return Run(env, output, os.Stderr, "go", params.WorkDir, args...)
}

func Run(env map[string]string, stdout, stderr io.Writer, cmd string, workingDir string, args ...string) (err error) {
expand := func(s string) string {
s2, ok := env[s]
if ok {
return s2
}
return os.Getenv(s)
}
cmd = os.Expand(cmd, expand)
for i := range args {
args[i] = os.Expand(args[i], expand)
}

c := exec.Command(cmd, args...)
c.Env = os.Environ()
for k, v := range env {
c.Env = append(c.Env, k+"="+v)
}
c.Dir = workingDir
c.Stderr = stderr
c.Stdout = stdout
c.Stdin = os.Stdin

var quoted []string
for i := range args {
quoted = append(quoted, fmt.Sprintf("%q", args[i]))
}
// To protect against logging from doing exec in global variables
if mg.Verbose() {
log.Println("exec:", cmd, strings.Join(quoted, " "))
}
err = c.Run()
return err
}

// MakeWindowsSysoFile generates a .syso file containing metadata about the
Expand Down
13 changes: 11 additions & 2 deletions dev-tools/mage/target/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ package update

import (
"fmt"
"os"

"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"

"github.com/elastic/elastic-agent/dev-tools/mage"
"github.com/elastic/elastic-agent/dev-tools/mage/target/common"
)

Expand All @@ -23,7 +24,15 @@ func Beats(targetVersion string) error {

func BeatsModule(targetVersion string) error {
goArgs := []string{"get", fmt.Sprintf("%s@%s", BeatsModulePath, targetVersion)}
err := sh.RunV(mg.GoCmd(), goArgs...)

fmt.Println("Updating beats module in edot package")
err := mage.Run(nil, os.Stdout, os.Stderr, "go", "internal/edot", goArgs...)
if err != nil {
return err
}

fmt.Println("Updating beats module in elastic-agent package")
err = mage.Run(nil, os.Stdout, os.Stderr, "go", "", goArgs...)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions dev-tools/notice/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
{"name": "github.com/grpc-ecosystem/go-grpc-middleware/v2", "licenceFile": "LICENSE", "licenceType": "Apache-2.0"}
{"name": "github.com/JohnCGriffin/overflow", "licenceFile": "README.md", "licenceType": "MIT"}
{"name": "github.com/elastic/cloud-on-k8s/v2", "licenceType": "Elastic"}
{"name": "github.com/elastic/elastic-agent/internal/edot", "licenceType": "Elastic"}
Loading