Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify getting the secret value #5

Merged
merged 1 commit into from
Nov 26, 2024
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
11 changes: 1 addition & 10 deletions hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,9 @@ function load_secret_into_env() {

function get_secret_value() {
local secret_name="$1"
local secret_version
local secret_value

secret_version=$(gcloud secrets versions list "${secret_name}" --format=json | jq -r '.[0].name')
secret_version="${secret_version##*/}"

local result=$?
if [[ $result -ne 0 ]]; then
exit 1
fi

secret_value=$(gcloud secrets versions access "${secret_version}" \
secret_value=$(gcloud secrets versions access latest \
--secret="${secret_name}" \
--format='get(payload.data)' | tr '_-' '/+' | base64 -d)

Expand Down