Skip to content

Commit 511603a

Browse files
committed
feat: Address shellcheck linting warnings in entrypoint.sh
- Declare and assign variables separately to avoid masking return values (SC2155)
1 parent 60d922f commit 511603a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

log-collector/entrypoint.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,18 @@ is_running_on_gcp() {
4747
# Function to detect if running on AWS using IMDSv2 only
4848
is_running_on_aws() {
4949
local timeout=5
50-
local response=$(curl -s -w "\n%{http_code}" -m "${timeout}" -X PUT \
50+
local response
51+
local http_code
52+
local token
53+
54+
response=$(curl -s -w "\n%{http_code}" -m "${timeout}" -X PUT \
5155
"http://169.254.169.254/latest/api/token" \
5256
-H "X-aws-ec2-metadata-token-ttl-seconds: 21600" 2>/dev/null)
5357

54-
local http_code=$(echo "$response" | tail -n1)
58+
http_code=$(echo "$response" | tail -n1)
5559
[ "$http_code" != "200" ] && return 1
56-
local token=$(echo "$response" | head -n-1)
60+
61+
token=$(echo "$response" | head -n-1)
5762
curl -s -m "${timeout}" -H "X-aws-ec2-metadata-token: ${token}" \
5863
"http://169.254.169.254/latest/meta-data/" >/dev/null 2>&1
5964
}

0 commit comments

Comments
 (0)