Skip to content

Commit

Permalink
chore: refactor handling of LOOKERSDK_CLIENT_ID and _SECRET (#939)
Browse files Browse the repository at this point in the history
* chore: refactor handling of LOOKERSDK_CLIENT_ID and _SECRET to work better with matrix.looker

* chore: incorporate Joel's comments

* chore: fixed .bash vs .sh
  • Loading branch information
drstrangelooker authored Jan 13, 2022
1 parent 948b5af commit 1b13712
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
16 changes: 16 additions & 0 deletions .github/scripts/parse_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

BEFORE_MAJ=21
BEFORE_MIN=18
IFS=_ read -r maj min
if [ "$maj" -lt "$BEFORE_MAJ" ]; then
echo "${maj}_${min}"
elif [ "$maj" -eq "$BEFORE_MAJ" ]; then
if [ "$min" -lt "$BEFORE_MIN" ]; then
echo "${maj}_${min}"
else
echo "21_18"
fi
else
echo "21_18"
fi
20 changes: 16 additions & 4 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,24 @@ jobs:
python -m pip install --upgrade pip
pip install tox
- name: Set LOOKERSDK_CLIENT_{ID,SECRET}
# api client/secret stored as github secret per release, e.g. LOOKERSDK_CLIENT_ID__7_20
- name: Determine credentials version
# Prior to 21_18, each version had different credentials and a
# different secret. 21_20 and later all use the same credentials
# as 21_18. The parse_version.sh script parses the version and
# yields 21_12, 21_14, 21_16 etc for those versions but 21_18 for
# anything 21_18, 21_20, 22_0, etc.
#
# This can be factored out entirely once 21_18 is the earliest
# supported looker version.
run: |
echo "LOOKERSDK_CLIENT_ID=${{ secrets[format('LOOKERSDK_CLIENT_ID__{0}', matrix.looker)] }}" >> $GITHUB_ENV
echo "LOOKERSDK_CLIENT_SECRET=${{ secrets[format('LOOKERSDK_CLIENT_SECRET__{0}', matrix.looker)] }}" >> $GITHUB_ENV
echo "CREDENTIALS_VERSION=$(${{ github.workspace }}/.github/scripts/parse_version.sh <<< ${{ matrix.looker }})" >> $GITHUB_ENV
- name: Set up Looker credentials
# Load the correct credentials based on the version from
# the prior step.
run: |
echo "LOOKERSDK_CLIENT_ID=${{ secrets[format('LOOKERSDK_CLIENT_ID__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
echo "LOOKERSDK_CLIENT_SECRET=${{ secrets[format('LOOKERSDK_CLIENT_SECRET__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
- name: Check that Looker is ready
run: |
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/tssdk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,24 @@ jobs:
yarn
yarn build
- name: Set LOOKERSDK_CLIENT_{ID,SECRET}
# api client/secret stored as github secret per release, e.g. LOOKERSDK_CLIENT_ID__7_20
- name: Determine credentials version
# Prior to 21_18, each version had different credentials and a
# different secret. 21_20 and later all use the same credentials
# as 21_18. The parse_version.sh script parses the version and
# yields 21_12, 21_14, 21_16 etc for those versions but 21_18 for
# anything 21_18, 21_20, 22_0, etc.
#
# This can be factored out entirely once 21_18 is the earliest
# supported looker version.
run: |
echo "LOOKERSDK_CLIENT_ID=${{ secrets[format('LOOKERSDK_CLIENT_ID__{0}', matrix.looker)] }}" >> $GITHUB_ENV
echo "LOOKERSDK_CLIENT_SECRET=${{ secrets[format('LOOKERSDK_CLIENT_SECRET__{0}', matrix.looker)] }}" >> $GITHUB_ENV
echo "CREDENTIALS_VERSION=$(${{ github.workspace }}/.github/scripts/parse_version.sh <<< ${{ matrix.looker }})" >> $GITHUB_ENV
- name: Set up Looker credentials
# Load the correct credentials based on the version from
# the prior step.
run: |
echo "LOOKERSDK_CLIENT_ID=${{ secrets[format('LOOKERSDK_CLIENT_ID__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
echo "LOOKERSDK_CLIENT_SECRET=${{ secrets[format('LOOKERSDK_CLIENT_SECRET__{0}', env.CREDENTIALS_VERSION )] }}" >> $GITHUB_ENV
- name: Check that Looker is ready
run: |
Expand Down

0 comments on commit 1b13712

Please sign in to comment.