From a42555c6a07b582afec641d4b5eda4a821c886cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 13:57:40 -0700 Subject: [PATCH] Preserve "flavor/color" in EKS cluster name abbreviation (#956) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/docker.yml | 2 +- os/alpine/requirements.txt | 2 +- rootfs/etc/profile.d/geodesic.kube-ps1.sh | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5db6dda5..d5c67835 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -35,7 +35,7 @@ jobs: - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v4 with: - role-to-assume: ${{ secrets.ECR_AWS_ROLE }} + role-to-assume: ${{ vars.ECR_AWS_ROLE }} aws-region: ${{ env.AWS_REGION }} role-session-name: ${{ env.IAM_ROLE_SESSION_NAME }} diff --git a/os/alpine/requirements.txt b/os/alpine/requirements.txt index c3cce420..422013d1 100644 --- a/os/alpine/requirements.txt +++ b/os/alpine/requirements.txt @@ -1,4 +1,4 @@ -cryptography==42.0.7 +cryptography==43.0.1 PyYAML==6.0.1 awscli==1.33.10 boto3==1.34.128 diff --git a/rootfs/etc/profile.d/geodesic.kube-ps1.sh b/rootfs/etc/profile.d/geodesic.kube-ps1.sh index 45e8b21f..f97c4833 100755 --- a/rootfs/etc/profile.d/geodesic.kube-ps1.sh +++ b/rootfs/etc/profile.d/geodesic.kube-ps1.sh @@ -40,8 +40,13 @@ function short_cluster_name_from_eks() { local full_name=$(printf "%s" "$1" | cut -d/ -f2) # remove namespace prefix if present full_name=${full_name#${NAMESPACE}-} - # remove eks and everything after it, if present - full_name=${full_name%-eks-*} + # remove "-eks" and "-cluster" if present, leave the rest + full_name=${full_name/-eks-/-} + if [[ "$full_name" =~ -cluster(-.*)?$ ]]; then + # If true, remove '-cluster' + full_name="${full_name/-cluster/}" + fi + printf "%s" "${full_name}" # If NAMESPACE is unset, delete everything before and including the first dash # printf "%s" "$1" | sed -e 's%arn.*:cluster/'"${NAMESPACE:-[^-]\+}"'-\([^-]\+\)-eks-.*$%\1%'