Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions providers/amazon/src/airflow/providers/amazon/aws/hooks/eks.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,25 @@ class NodegroupStates(Enum):


COMMAND = """
export PYTHON_OPERATORS_VIRTUAL_ENV_MODE=1
output=$({python_executable} -m airflow.providers.amazon.aws.utils.eks_get_token \
--cluster-name {eks_cluster_name} {args} 2>&1)

if [ $? -ne 0 ]; then
echo "Error running the script"
exit 1
status=$?

if [ "$status" -ne 0 ]; then
printf '%s' "$output" >&2
exit "$status"
fi

expiration_timestamp=$(echo "$output" | grep -oP 'expirationTimestamp: \\K[^,]+')
token=$(echo "$output" | grep -oP 'token: \\K[^,]+')
# Use pure bash below to parse so that it's posix compliant

last_line=${{output##*$'\\n'}} # strip everything up to the last newline

timestamp=${{last_line#expirationTimestamp: }} # drop the label
timestamp=${{timestamp%%,*}} # keep up to the first comma

token=${{last_line##*, token: }} # text after ", token: "

json_string=$(printf '{{"kind": "ExecCredential","apiVersion": \
"client.authentication.k8s.io/v1alpha1","spec": {{}},"status": \
Expand Down
Loading