Skip to content

Commit 79b0d63

Browse files
authored
[kokoro] testing: use secrets manager (#3857)
1 parent a3a1e40 commit 79b0d63

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

.kokoro/lint/common.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Configure the docker image for kokoro-trampoline.
1818
env_vars: {
1919
key: "TRAMPOLINE_IMAGE"
20-
value: "gcr.io/cloud-devrel-kokoro-resources/python"
20+
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
2121
}
2222

2323
# Download trampoline resources.

.kokoro/tests/run_tests.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ cd github/python-docs-samples
3737
# install nox for testing
3838
pip install -q nox
3939

40-
# Unencrypt and extract secrets
41-
SECRETS_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secrets-password.txt")
42-
./scripts/decrypt-secrets.sh "${SECRETS_PASSWORD}"
40+
# Use secrets acessor service account to get secrets
41+
gcloud auth activate-service-account \
42+
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
43+
--project="cloud-devrel-kokoro-resources"
44+
./scripts/decrypt-secrets.sh
4345

4446
source ./testing/test-env.sh
4547
export GOOGLE_APPLICATION_CREDENTIALS=$(pwd)/testing/service-account.json

scripts/decrypt-secrets.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ ROOT=$( dirname "$DIR" )
2020
# Work from the project root.
2121
cd $ROOT
2222

23-
openssl aes-256-cbc -k "$1" -md sha256 \
24-
-in testing/secrets.tar.enc -out secrets.tar -d
25-
tar xvf secrets.tar
26-
rm secrets.tar
23+
gcloud secrets versions access latest --secret="python-docs-samples-test-env" > testing/test-env.sh
24+
gcloud secrets versions access latest --secret="python-docs-samples-service-account" > testing/service-account.json
25+
gcloud secrets versions access latest --secret="python-docs-samples-client-secrets" > testing/client-secrets.json

scripts/encrypt-secrets.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ ROOT=$( dirname "$DIR" )
2020
# Work from the project root.
2121
cd $ROOT
2222

23-
read -s -p "Enter password for encryption: " PASSWORD
24-
echo
25-
26-
tar cvf secrets.tar testing/{service-account.json,client-secrets.json,test-env.sh}
27-
openssl aes-256-cbc -k "$PASSWORD" -md sha256 \
28-
-in secrets.tar -out testing/secrets.tar.enc
29-
rm secrets.tar
23+
gcloud secrets versions add "python-docs-samples-test-env" --data-file="testing/test-env.sh"
24+
gcloud secrets versions add "python-docs-samples-service-account" --data-file="testing/service-account.json"
25+
gcloud secrets versions add "python-docs-samples-client-secrets" --data-file="testing/test-env.sh"

testing/secrets.tar.enc

-11 KB
Binary file not shown.

0 commit comments

Comments
 (0)