Repository navigation
chore(kokoro): Fetch latest enabled secret instead of disabled latest version #14730
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,12 +28,27 @@ mkdir -p ${SECRET_LOCATION} | |||||||||||||||||||||||||||||
| for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") | ||||||||||||||||||||||||||||||
| do | ||||||||||||||||||||||||||||||
| msg "Retrieving secret ${key}" | ||||||||||||||||||||||||||||||
| docker run --entrypoint=gcloud \ | ||||||||||||||||||||||||||||||
| --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \ | ||||||||||||||||||||||||||||||
| VERSION=$(docker run --rm --entrypoint=gcloud \ | ||||||||||||||||||||||||||||||
| --volume="${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}" \ | ||||||||||||||||||||||||||||||
| gcr.io/google.com/cloudsdktool/cloud-sdk \ | ||||||||||||||||||||||||||||||
| secrets versions access latest \ | ||||||||||||||||||||||||||||||
| secrets versions list "${key}" \ | ||||||||||||||||||||||||||||||
| --project cloud-devrel-kokoro-resources \ | ||||||||||||||||||||||||||||||
| --secret ${key} > \ | ||||||||||||||||||||||||||||||
| --filter="state=enabled" \ | ||||||||||||||||||||||||||||||
| --sort-by="~createTime" \ | ||||||||||||||||||||||||||||||
| --limit=1 \ | ||||||||||||||||||||||||||||||
| --format="value(name.basename())") || VERSION="" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| if [ -z "${VERSION}" ]; then | ||||||||||||||||||||||||||||||
| msg "Error retrieving enabled version for secret ${key}" | ||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| docker run --rm --entrypoint=gcloud \ | ||||||||||||||||||||||||||||||
| --volume="${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}" \ | ||||||||||||||||||||||||||||||
| gcr.io/google.com/cloudsdktool/cloud-sdk \ | ||||||||||||||||||||||||||||||
| secrets versions access "${VERSION}" \ | ||||||||||||||||||||||||||||||
| --project cloud-devrel-kokoro-resources \ | ||||||||||||||||||||||||||||||
| --secret "${key}" > \ | ||||||||||||||||||||||||||||||
| "${SECRET_LOCATION}/${key}" | ||||||||||||||||||||||||||||||
|
sakthivelmanii marked this conversation as resolved.
Comment on lines
+46
to
52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the
Suggested change
|
||||||||||||||||||||||||||||||
| if [[ $? == 0 ]]; then | ||||||||||||||||||||||||||||||
| msg "Secret written to ${SECRET_LOCATION}/${key}" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.