Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

docs: add samples from kms/api-client #14

Merged
merged 55 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3fcf98f
Python KMS Apiary P1 samples [(#779)](https://github.com/GoogleCloudP…
ryanmats Feb 7, 2017
1f3c3b9
random generation of keyring / cryptokey names [(#786)](https://githu…
ryanmats Feb 8, 2017
d3c9a9b
Auto-update dependencies. [(#790)](https://github.com/GoogleCloudPlat…
dpebot Feb 9, 2017
2f0e389
Remove usage of GoogleCredentials [(#810)](https://github.com/GoogleC…
Feb 17, 2017
27611b3
Updates Could-KMS sample code to use V1 libraries. [(#856)](https://g…
philcoakley Mar 16, 2017
57dbdb1
Remove cloud config fixture [(#887)](https://github.com/GoogleCloudPl…
Apr 4, 2017
fa6ee74
Re-generate all readmes
Apr 27, 2017
966d0d9
KMS: Clean up base64 logic in the encrypt and decrypt functions. [(#1…
Aug 16, 2017
77e5c1a
KMS: Make the samples consistent with the other languages. [(#1075)](…
Aug 17, 2017
aa49dbc
Auto-update dependencies. [(#1094)](https://github.com/GoogleCloudPla…
dpebot Aug 30, 2017
04e00af
Update all generated readme auth instructions [(#1121)](https://githu…
Sep 18, 2017
5156f09
Auto-update dependencies. [(#1133)](https://github.com/GoogleCloudPla…
dpebot Sep 21, 2017
f894679
Added Link to Python Setup Guide [(#1158)](https://github.com/GoogleC…
Oct 12, 2017
98fa815
Auto-update dependencies. [(#1186)](https://github.com/GoogleCloudPla…
dpebot Nov 1, 2017
091dbc6
Adds snippets for enabling and restoring a key version [(#1196)](http…
WalterHub Nov 7, 2017
ff973d8
Auto-update dependencies. [(#1217)](https://github.com/GoogleCloudPla…
dpebot Nov 15, 2017
b9a4c34
Added "Open in Cloud Shell" buttons to README files [(#1254)](https:/…
Dec 7, 2017
251d796
Auto-update dependencies. [(#1309)](https://github.com/GoogleCloudPla…
dpebot Jan 10, 2018
091bcac
Auto-update dependencies. [(#1320)](https://github.com/GoogleCloudPla…
dpebot Feb 2, 2018
c4f16b4
Auto-update dependencies. [(#1355)](https://github.com/GoogleCloudPla…
dpebot Feb 9, 2018
4f3ccbf
Auto-update dependencies. [(#1359)](https://github.com/GoogleCloudPla…
dpebot Feb 26, 2018
7264e6a
Auto-update dependencies.
dpebot Apr 2, 2018
d140516
Regenerate the README files and fix the Open in Cloud Shell link for …
Apr 7, 2018
2857b8d
Update READMEs to fix numbering and add git clone [(#1464)](https://g…
frankyn Apr 26, 2018
cf6aa1a
Resolved conflicts.
michaelawyu Jun 29, 2018
6e26023
Merge branch 'dpebot-repositorygardener' despite flaky dataproc tests
michaelawyu Jun 29, 2018
e2c0637
added kms asymmetric samples [(#1638)](https://github.com/GoogleCloud…
daniel-sanche Aug 17, 2018
45107a0
kms text fixes [(#1647)](https://github.com/GoogleCloudPlatform/pytho…
daniel-sanche Aug 22, 2018
8cbac2e
KMS test fix [(#1690)](https://github.com/GoogleCloudPlatform/python-…
daniel-sanche Sep 7, 2018
c6ac726
KMS changes [(#1723)](https://github.com/GoogleCloudPlatform/python-d…
daniel-sanche Sep 28, 2018
2b8e5e1
KMS import comments [(#1771)](https://github.com/GoogleCloudPlatform/…
daniel-sanche Oct 25, 2018
9a7aa6c
Auto-update dependencies. [(#1846)](https://github.com/GoogleCloudPla…
dpebot Nov 20, 2018
0f27818
Auto-update dependencies. [(#1862)](https://github.com/GoogleCloudPla…
dpebot Nov 21, 2018
15d486d
KMS: Updated for new client library [(#1903)](https://github.com/Goog…
daniel-sanche Jan 7, 2019
7b25fbc
Auto-update dependencies. [(#1980)](https://github.com/GoogleCloudPla…
dpebot Feb 6, 2019
fe32c0c
Move import statements into tagged regions [(#2219)](https://github.c…
engelke Jun 13, 2019
dc0df22
Adds split updates for Firebase ... opencensus [(#2438)](https://gith…
gguuss Oct 8, 2019
18100cc
Auto-update dependencies. [(#2005)](https://github.com/GoogleCloudPla…
dpebot Dec 21, 2019
17f78cf
chore(deps): update dependency google-cloud-kms to v1.3.0 [(#3160)](h…
renovate-bot Mar 30, 2020
a4df66a
Simplify noxfile setup. [(#2806)](https://github.com/GoogleCloudPlatf…
kurtisvg Apr 2, 2020
e1fe4da
[kms] fix flaky test [(#3268)](https://github.com/GoogleCloudPlatform…
daniel-sanche Apr 7, 2020
b376b7b
Update dependency google-cloud-kms to v1.4.0 [(#3410)](https://github…
renovate-bot Apr 21, 2020
5581e83
chore(deps): update dependency cryptography to v2.9 [(#3266)](https:/…
renovate-bot Apr 22, 2020
b33aa1c
fix: use `crypto_key_path` instead of `crypto_key_path_path` [(#3319)…
busunkim96 Apr 22, 2020
1e095c3
chore(deps): update dependency cryptography to v2.9.1 [(#3463)](https…
renovate-bot Apr 22, 2020
aa5277b
[kms] chore: remove gcp-devrel-py-tools [(#3479)](https://github.com/…
Apr 23, 2020
6283510
Update dependency cryptography to v2.9.2 [(#3473)](https://github.com…
renovate-bot Apr 23, 2020
2f018a3
[kms] fix: use unique ids for test [(#3563)](https://github.com/Googl…
Apr 28, 2020
97d80d5
Update and add Cloud KMS samples [(#3690)](https://github.com/GoogleC…
sethvargo May 5, 2020
1b1d5da
chore: some lint fixes [(#3748)](https://github.com/GoogleCloudPlatfo…
May 13, 2020
309319a
Merge branch 'snippets-samples' into add-snippets-samples
busunkim96 May 28, 2020
2bc9430
chore: update templates
busunkim96 May 28, 2020
515d022
chore: update templates
busunkim96 May 28, 2020
990e7a6
chore: update docs index
busunkim96 May 28, 2020
7b36aeb
chore: only trigger review for python file changes
busunkim96 Jun 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
Expand Down
8 changes: 8 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Code owners file.
# This file controls who is tagged for review for any given pull request.
#
# For syntax help see:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax


/samples/**/*.py @DanSanche @googleapis/python-samples-owners
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
Expand Down Expand Up @@ -49,6 +50,7 @@ bigquery/docs/generated
# Virtual environment
env/
coverage.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
2 changes: 0 additions & 2 deletions .kokoro/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Disable buffering, so that the logs stream through.
Expand Down
2 changes: 0 additions & 2 deletions .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Start the releasetool reporter
Expand Down
34 changes: 34 additions & 0 deletions .kokoro/samples/lint/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "lint"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-kms/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-kms/.kokoro/trampoline.sh"
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/periodic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/lint/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
34 changes: 34 additions & 0 deletions .kokoro/samples/python3.6/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.6"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-kms/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-kms/.kokoro/trampoline.sh"
7 changes: 7 additions & 0 deletions .kokoro/samples/python3.6/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}

6 changes: 6 additions & 0 deletions .kokoro/samples/python3.6/periodic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.6/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
34 changes: 34 additions & 0 deletions .kokoro/samples/python3.7/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.7"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-kms/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-kms/.kokoro/trampoline.sh"
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.7/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.7/periodic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.7/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
34 changes: 34 additions & 0 deletions .kokoro/samples/python3.8/common.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Format: //devtools/kokoro/config/proto/build.proto

# Build logs will be here
action {
define_artifacts {
regex: "**/*sponge_log.xml"
}
}

# Specify which tests to run
env_vars: {
key: "RUN_TESTS_SESSION"
value: "py-3.8"
}

env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-kms/.kokoro/test-samples.sh"
}

# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
}

# Download secrets for samples
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"

# Download trampoline resources.
gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"

# Use the trampoline script to run in docker.
build_file: "python-kms/.kokoro/trampoline.sh"
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.8/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.8/periodic.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "False"
}
6 changes: 6 additions & 0 deletions .kokoro/samples/python3.8/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Format: //devtools/kokoro/config/proto/build.proto

env_vars: {
key: "INSTALL_LIBRARY_FROM_SOURCE"
value: "True"
}
104 changes: 104 additions & 0 deletions .kokoro/test-samples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# `-e` enables the script to automatically fail when a command fails
# `-o pipefail` sets the exit code to the rightmost comment to exit with a non-zero
set -eo pipefail
# Enables `**` to include files nested inside sub-folders
shopt -s globstar

cd github/python-kms

# Run periodic samples tests at latest release
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
LATEST_RELEASE=$(git describe --abbrev=0 --tags)
git checkout $LATEST_RELEASE
fi

# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1

# Debug: show build environment
env | grep KOKORO

# Install nox
python3.6 -m pip install --upgrade --quiet nox

# Use secrets acessor service account to get secrets
if [[ -f "${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" ]]; then
gcloud auth activate-service-account \
--key-file="${KOKORO_GFILE_DIR}/secrets_viewer_service_account.json" \
--project="cloud-devrel-kokoro-resources"
fi

# This script will create 3 files:
# - testing/test-env.sh
# - testing/service-account.json
# - testing/client-secrets.json
./scripts/decrypt-secrets.sh

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

# For cloud-run session, we activate the service account for gcloud sdk.
gcloud auth activate-service-account \
--key-file "${GOOGLE_APPLICATION_CREDENTIALS}"

export GOOGLE_CLIENT_SECRETS=$(pwd)/testing/client-secrets.json

echo -e "\n******************** TESTING PROJECTS ********************"

# Switch to 'fail at end' to allow all tests to complete before exiting.
set +e
# Use RTN to return a non-zero value if the test fails.
RTN=0
ROOT=$(pwd)
# Find all requirements.txt in the samples directory (may break on whitespace).
for file in samples/**/requirements.txt; do
cd "$ROOT"
# Navigate to the project folder.
file=$(dirname "$file")
cd "$file"

echo "------------------------------------------------------------"
echo "- testing $file"
echo "------------------------------------------------------------"

# Use nox to execute the tests for the project.
python3.6 -m nox -s "$RUN_TESTS_SESSION"
EXIT=$?

# If this is a periodic build, send the test log to the Build Cop Bot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop
$KOKORO_GFILE_DIR/linux_amd64/buildcop
fi

if [[ $EXIT -ne 0 ]]; then
RTN=1
echo -e "\n Testing failed: Nox returned a non-zero exit code. \n"
else
echo -e "\n Testing completed.\n"
fi

done
cd "$ROOT"

# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}

exit "$RTN"