Skip to content

Commit

Permalink
chore(py-library): update decrypt secrets file (#745)
Browse files Browse the repository at this point in the history
* chore(py-library): update decrypt secrets file

From https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/scripts/decrypt-secrets.sh

* docs: explain conditional

Co-authored-by: Jeffrey Rennie <rennie@google.com>
  • Loading branch information
busunkim96 and SurferJeffAtGoogle authored Sep 8, 2020
1 parent 470e988 commit d302f93
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,27 @@ ROOT=$( dirname "$DIR" )
# Work from the project root.
cd $ROOT

# Prevent it from overriding files.
# We recommend that sample authors use their own service account files and cloud project.
# In that case, they are supposed to prepare these files by themselves.
if [[ -f "testing/test-env.sh" ]] || \
[[ -f "testing/service-account.json" ]] || \
[[ -f "testing/client-secrets.json" ]]; then
echo "One or more target files exist, aborting."
exit 1
fi

# Use SECRET_MANAGER_PROJECT if set, fallback to cloud-devrel-kokoro-resources.
PROJECT_ID="${SECRET_MANAGER_PROJECT:-cloud-devrel-kokoro-resources}"

gcloud secrets versions access latest --secret="python-docs-samples-test-env" \
--project="${PROJECT_ID}" \
> testing/test-env.sh
gcloud secrets versions access latest \
--secret="python-docs-samples-service-account" \
--project="${PROJECT_ID}" \
> testing/service-account.json
gcloud secrets versions access latest \
--secret="python-docs-samples-client-secrets" \
> testing/client-secrets.json
--project="${PROJECT_ID}" \
> testing/client-secrets.json

0 comments on commit d302f93

Please sign in to comment.