Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add otelcol shortcut to elastic-agent otel #4816

Merged
merged 14 commits into from
Jun 6, 2024
Merged
5 changes: 5 additions & 0 deletions dev-tools/packaging/files/darwin/elastic-otel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

BASEDIR=$(dirname "$0")

exec $BASEDIR/elastic-agent otel $@

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Darwin and Linux I believe we actually want

exec "$BASEDIR/elastic-agent" otel "$@"

If you put elastic-agent into a folder with a space and then cd to root and try to run it, it will fail due to the space without the path being quoted.

In addition I believe $@ needs to be in quotes:

($@) Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word.

./a.sh 2 "3     4" 5
2 3     4 5                  # output for "$@"
2 3 4 5                      # output for $@  -> spaces are lost!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, run shellcheck on this and it should find this problem and any other Bash quirks.

5 changes: 5 additions & 0 deletions dev-tools/packaging/files/linux/elastic-otel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

BASEDIR=$(dirname "$0")

exec $BASEDIR/elastic-agent otel $@
2 changes: 2 additions & 0 deletions dev-tools/packaging/files/windows/elastic-otel.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$workdir = Split-Path $MyInvocation.MyCommand.Path
& "$workdir\elastic-agent" otel $args
28 changes: 24 additions & 4 deletions dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ shared:
mode: 0755
config_mode: 0644
skip_on_missing: true

- &linux_otel_files
'elastic-otel':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/linux/elastic-otel.sh'
mode: 0755
'data/{{.BeatName}}-{{ commit_short }}/elastic-otel':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/linux/elastic-otel.sh'
mode: 0755

- &agent_binary_common_files
LICENSE.txt:
Expand Down Expand Up @@ -201,6 +209,12 @@ shared:
content: >
{{ agent_package_version }}
mode: 0644
'elastic-otel':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/darwin/elastic-otel.sh'
mode: 0755
'data/{{.BeatName}}-{{ commit_short }}/elastic-otel':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/darwin/elastic-otel.sh'
mode: 0755
<<: *agent_darwin_app_bundle_files
<<: *agent_binary_common_files

Expand All @@ -217,6 +231,7 @@ shared:
files:
<<: *agent_binary_files
<<: *agent_components
<<: *linux_otel_files


- &agent_darwin_binary_spec
Expand All @@ -235,6 +250,12 @@ shared:
mode: 0755
config_mode: 0644
skip_on_missing: true
'elastic-otel.ps1':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/windows/elastic-otel.ps1'
mode: 0755
'data/{{.BeatName}}-{{ commit_short }}/elastic-otel.ps1':
source: '{{ repo.RootDir }}/dev-tools/packaging/files/windows/elastic-otel.ps1'
mode: 0755

- &agent_docker_spec
<<: *agent_binary_spec
Expand Down Expand Up @@ -811,10 +832,7 @@ specs:
'data/{{.BeatName}}-{{ commit_short }}/elastic-agent':
template: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/darwin/elastic-agent.tmpl'
mode: 0755
'{{.BeatName}}{{.BinaryExt}}':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I will re-add this

source: data/{{.BeatName}}-{{ commit_short }}/elastic-agent.app/Contents/MacOS/{{.BeatName}}{{.BinaryExt}}
symlink: true
mode: 0755


- os: linux
types: [tgz]
Expand Down Expand Up @@ -1005,6 +1023,8 @@ specs:
files:
'{{.BeatName}}{{.BinaryExt}}':
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
'{{.BeatName}}{{.BinaryExt}}':
source: ./build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}

- os: linux
types: [tgz]
Expand Down
Loading