Skip to content

Commit d76d6c3

Browse files
authored
Fix method of obtaining service account token (#3199)
1 parent 68a1452 commit d76d6c3

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

e2e/live/end-to-end-test.sh

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,16 +1187,11 @@ wait 2
11871187
# Setup: use the service account just created. It does not have permissions
11881188
# on the default namespace, so it will give a permissions error on apply
11891189
# for anything attempted to apply to the default namespace.
1190-
echo "kubectl get sa user -ojsonpath='{.secrets[0].name}'"
1191-
SECRET_NAME="$(kubectl get sa user -ojsonpath='{.secrets[0].name}')"
1192-
if [[ -z "${SECRET_NAME}" ]]; then
1193-
# K8s 1.24+ doesn't auto-generate service account secrets any more.
1194-
echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2"
1195-
kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status
1196-
assertContains "secret/user-credentials created"
1197-
wait 2
1198-
SECRET_NAME="user-credentials"
1199-
fi
1190+
echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2"
1191+
kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status
1192+
assertContains "secret/user-credentials created"
1193+
wait 2
1194+
SECRET_NAME="user-credentials"
12001195
echo "kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d"
12011196
SECRET_TOKEN="$(kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d)"
12021197
echo "kubectl config set-credentials user --token \"<REDACTED>\""
@@ -1446,16 +1441,11 @@ wait 2
14461441
# Setup: use the service account just created. It does not have permissions
14471442
# on the default namespace, so it will give a permissions error on apply
14481443
# for anything attempted to apply to the default namespace.
1449-
echo "kubectl get sa user -ojsonpath='{.secrets[0].name}'"
1450-
SECRET_NAME="$(kubectl get sa user -ojsonpath='{.secrets[0].name}')"
1451-
if [[ -z "${SECRET_NAME}" ]]; then
1452-
# K8s 1.24+ doesn't auto-generate service account secrets any more.
1453-
echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2"
1454-
kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status
1455-
assertContains "secret/user-credentials created"
1456-
wait 2
1457-
SECRET_NAME="user-credentials"
1458-
fi
1444+
echo "kubectl apply -f e2e/live/testdata/rbac-error-step-2"
1445+
kubectl apply -f e2e/live/testdata/rbac-error-step-2 2>&1 | tee $OUTPUT_DIR/status
1446+
assertContains "secret/user-credentials created"
1447+
wait 2
1448+
SECRET_NAME="user-credentials"
14591449
echo "kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d"
14601450
SECRET_TOKEN="$(kubectl get secrets -ojsonpath='{.data.token}' "${SECRET_NAME}" | base64 -d)"
14611451
echo "kubectl config set-credentials user --token \"<REDACTED>\""

0 commit comments

Comments
 (0)