File tree Expand file tree Collapse file tree 2 files changed +10
-127
lines changed
Expand file tree Collapse file tree 2 files changed +10
-127
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,16 @@ let
108108 echo "Agent ${ vm } already registered, skipping token generation"
109109 else
110110 echo "Generating new token for ${ vm } "
111- token="$(spire-server token generate \
112- -socketPath ${ socketPath } \
113- -spiffeID spiffe://${ cfg . trustDomain } /${ vm } \
114- | awk '/^Token:/ {print $2}')"
111+ output=$(spire-server token generate -socketPath "${ socketPath } " -spiffeID "spiffe://${ cfg . trustDomain } /${ vm } ")
112+
113+ # Check if the command actually worked
114+ if [ $? -ne 0 ]; then
115+ echo "Error: SPIRE token generation failed!" >&2
116+ exit 1
117+ fi
118+
119+ # Extract the token from the successful output
120+ token=$(echo "$output" | awk '/^Token:/ {print $2}')
115121
116122 printf '%s\n' "$token" > "$tokenFile"
117123 chmod 0644 "$tokenFile"
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments