Skip to content

Commit

Permalink
Merge branch 'main' into python-kms-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamborski authored Nov 9, 2022
2 parents b29b377 + b47c641 commit edad2f8
Show file tree
Hide file tree
Showing 42 changed files with 2,830 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
/billing/**/* @GoogleCloudPlatform/billing-samples-maintainers @GoogleCloudPlatform/python-samples-reviewers
/blog/**/* @GoogleCloudPlatform/python-samples-reviewers
/cdn/**/* @mpwarres @GoogleCloudPlatform/python-samples-reviewers
/cloudbuild/**/* @GoogleCloudPlatform/torus-dpe @GoogleCloudPlatform/python-samples-reviewers
/cloud-sql/**/* @GoogleCloudPlatform/infra-db-dpes @GoogleCloudPlatform/python-samples-reviewers
/codelabs/**/* @GoogleCloudPlatform/python-samples-reviewers
/composer/**/* @leahecole @rachael-ds @rafalbiegacz @GoogleCloudPlatform/python-samples-reviewers
Expand All @@ -49,7 +50,7 @@
/media_cdn/**/* @justin-mp @msampathkumar @GoogleCloudPlatform/python-samples-reviewers
/memorystore/**/* @GoogleCloudPlatform/python-samples-reviewers
/ml_engine/**/* @ivanmkc @GoogleCloudPlatform/python-samples-reviewers
/monitoring/**/* @GoogleCloudPlatform/python-samples-reviewers
/monitoring/**/* @GoogleCloudPlatform/dee-observability @GoogleCloudPlatform/python-samples-reviewers
/monitoring/opencensus @yuriatgoogle @GoogleCloudPlatform/python-samples-reviewers
/monitoring/prometheus @yuriatgoogle @GoogleCloudPlatform/python-samples-reviewers
/notebooks/**/* @alixhami @GoogleCloudPlatform/python-samples-reviewers
Expand Down
8 changes: 8 additions & 0 deletions .github/blunderbuss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ assign_issues_by:
- 'api: cloudbilling'
to:
- GoogleCloudPlatform/billing-samples-maintainers
- labels:
- 'api: cloudbuild'
to:
- GoogleCloudPlatform/torus-dpe
- labels:
- 'api: cloudsql'
to:
Expand Down Expand Up @@ -108,6 +112,10 @@ assign_issues_by:
- 'api: translate'
to:
- nicain
- labels:
- 'api: monitoring'
to:
- GoogleCloudPlatform/dee-observability

assign_prs_by:
- labels:
Expand Down
1 change: 1 addition & 0 deletions cloudbuild/AUTHORING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/AUTHORING_GUIDE.md
1 change: 1 addition & 0 deletions cloudbuild/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/CONTRIBUTING.md
40 changes: 40 additions & 0 deletions cloudbuild/snippets/noxfile_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2021 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
#
# http://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.

# Default TEST_CONFIG_OVERRIDE for python repos.

# You can copy this file into your directory, then it will be imported from
# the noxfile.py.

# The source of truth:
# https://github.com/GoogleCloudPlatform/python-docs-samples/blob/main/noxfile_config.py

TEST_CONFIG_OVERRIDE = {
# You can opt out from the test for specific Python versions.
# NOTE: We currently only run the test in Python 3.8.
"ignored_versions": ["2.7"],
# Old samples are opted out of enforcing Python type hints
# All new samples should feature them
"enforce_type_hints": True,
# An envvar key for determining the project id to use. Change it
# to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a
# build specific Cloud project. You can also use your own string
# to use your own Cloud project.
"gcloud_project_env": "GOOGLE_CLOUD_PROJECT",
# 'gcloud_project_env': 'BUILD_SPECIFIC_GCLOUD_PROJECT',
# A dictionary you want to inject into your test. Don't put any
# secrets here. These values will override predefined values.
"envs": {
},
}
60 changes: 60 additions & 0 deletions cloudbuild/snippets/quickstart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright 2021 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
#
# http://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.


# [START cloudbuild_quickstart]
import google.auth
from google.cloud.devtools import cloudbuild_v1


def quickstart() -> None:
"""Create and execute a simple Google Cloud Build configuration,
print the in-progress status and print the completed status."""

# Authorize the client with Google defaults
credentials, project_id = google.auth.default()
client = cloudbuild_v1.services.cloud_build.CloudBuildClient()

# If you're using Private Pools or a non-global default pool, add a regional
# `api_endpoint` to `CloudBuildClient()`
# For example, '<YOUR_POOL_REGION>-cloudbuild.googleapis.com'
#
# from google.api_core import client_options
# client_options = client_options.ClientOptions(
# api_endpoint="us-central1-cloudbuild.googleapis.com"
# )
# client = cloudbuild_v1.services.cloud_build.CloudBuildClient(client_options=client_options)

build = cloudbuild_v1.Build()

# The following build steps will output "hello world"
# For more information on build configuration, see
# https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration
build.steps = [{"name": "ubuntu",
"entrypoint": "bash",
"args": ["-c", "echo hello world"]}]

operation = client.create_build(project_id=project_id, build=build)
# Print the in-progress operation
print("IN PROGRESS:")
print(operation.metadata)

result = operation.result()
# Print the completed status
print("RESULT:", result.status)
# [END cloudbuild_quickstart]


if __name__ == "__main__":
quickstart()
27 changes: 27 additions & 0 deletions cloudbuild/snippets/quickstart_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2021 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.


import pytest

import quickstart


def test_quickstart(capsys: pytest.CaptureFixture) -> None:
quickstart.quickstart()
out, _ = capsys.readouterr()
# Prints in-progress message
assert "hello world" in out
# Prints final status
assert "Status.SUCCESS" in out
1 change: 1 addition & 0 deletions cloudbuild/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==7.2.0
2 changes: 2 additions & 0 deletions cloudbuild/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
google-cloud-build==3.9.3
google-auth==2.14.0
Loading

0 comments on commit edad2f8

Please sign in to comment.