diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 00000000..d49860b3 --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,4 @@ +docker: + digest: sha256:457583330eec64daa02aeb7a72a04d33e7be2428f646671ce4045dcbc0191b1e + image: gcr.io/repo-automation-bots/owlbot-python:latest + diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 00000000..53345a02 --- /dev/null +++ b/.github/.OwlBot.yaml @@ -0,0 +1,26 @@ +# 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. + +docker: + image: gcr.io/repo-automation-bots/owlbot-python:latest + +deep-remove-regex: + - /owl-bot-staging + +deep-copy-regex: + - source: /google/container/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 130ce904e5d546c312943d10f48799590f9c0f66 + diff --git a/owlbot.py b/owlbot.py new file mode 100644 index 00000000..8f5ee2ad --- /dev/null +++ b/owlbot.py @@ -0,0 +1,98 @@ +# Copyright 2018 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. + +"""This script is used to synthesize generated parts of this library.""" +import synthtool as s +from synthtool import gcp + +common = gcp.CommonTemplates() + +default_version = "v1" + +for library in s.get_staging_dirs(default_version): + # Issues exist where python files should define the source encoding + # https://github.com/googleapis/gapic-generator/issues/2097 + s.replace( + library / "google/**/proto/*_pb2.py", + r"(^.*$\n)*", + r"# -*- coding: utf-8 -*-\n\g<0>") + + # Workaround https://github.com/googleapis/gapic-generator/issues/2449 + s.replace( + library / "google/**/proto/cluster_service_pb2.py", + r"nodePool>\n", + r"nodePool>`__\n", + ) + s.replace( + library / "google/**/proto/cluster_service_pb2.py", + r"(\s+)`__ instead", + r"\g<1>instead", + ) + + # Fix namespace + s.replace( + library / f"google/**/*.py", + f"google.container_{library.name}", + f"google.cloud.container_{library.name}", + ) + + s.replace( + library / f"tests/unit/gapic/**/*.py", + f"google.container_{library.name}", + f"google.cloud.container_{library.name}", + ) + + s.replace( + library / f"docs/**/*.rst", + f"google.container_{library.name}", + f"google.cloud.container_{library.name}", + ) + + # Fix package name + s.replace( + library / "google/**/*.py", + "google-container", + "google-cloud-container" + ) + + s.move(library / "google/container", "google/cloud/container") + s.move( + library / f"google/container_{library.name}", + f"google/cloud/container_{library.name}" + ) + s.move(library / "tests") + s.move(library / "scripts") + s.move(library / "docs", excludes=["index.rst"]) + +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- +templated_files = common.py_library( + samples=False, # set to True only if there are samples + microgenerator=True, + cov_level=99, +) +s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file + + +# TODO(busunkim): Use latest sphinx after microgenerator transition +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') + +# Temporarily disable warnings due to +# https://github.com/googleapis/gapic-generator-python/issues/525 +s.replace("noxfile.py", '[\"\']-W[\"\']', '# "-W"') + +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/synth.metadata b/synth.metadata deleted file mode 100644 index 0a29112b..00000000 --- a/synth.metadata +++ /dev/null @@ -1,155 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "https://github.com/googleapis/python-container.git", - "sha": "f908d5415c30ec66617ed63e7851f7d13cc06337" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "149a3a84c29c9b8189576c7442ccb6dcf6a8f95b", - "internalRef": "364411656" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "container", - "apiVersion": "v1beta1", - "language": "python", - "generator": "bazel" - } - }, - { - "client": { - "source": "googleapis", - "apiName": "container", - "apiVersion": "v1", - "language": "python", - "generator": "bazel" - } - } - ], - "generatedFiles": [ - ".flake8", - ".github/CONTRIBUTING.md", - ".github/ISSUE_TEMPLATE/bug_report.md", - ".github/ISSUE_TEMPLATE/feature_request.md", - ".github/ISSUE_TEMPLATE/support_request.md", - ".github/PULL_REQUEST_TEMPLATE.md", - ".github/header-checker-lint.yml", - ".github/release-please.yml", - ".github/snippet-bot.yml", - ".gitignore", - ".kokoro/build.sh", - ".kokoro/continuous/common.cfg", - ".kokoro/continuous/continuous.cfg", - ".kokoro/docker/docs/Dockerfile", - ".kokoro/docker/docs/fetch_gpg_keys.sh", - ".kokoro/docs/common.cfg", - ".kokoro/docs/docs-presubmit.cfg", - ".kokoro/docs/docs.cfg", - ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/presubmit.cfg", - ".kokoro/publish-docs.sh", - ".kokoro/release.sh", - ".kokoro/release/common.cfg", - ".kokoro/release/release.cfg", - ".kokoro/samples/lint/common.cfg", - ".kokoro/samples/lint/continuous.cfg", - ".kokoro/samples/lint/periodic.cfg", - ".kokoro/samples/lint/presubmit.cfg", - ".kokoro/samples/python3.6/common.cfg", - ".kokoro/samples/python3.6/continuous.cfg", - ".kokoro/samples/python3.6/periodic-head.cfg", - ".kokoro/samples/python3.6/periodic.cfg", - ".kokoro/samples/python3.6/presubmit.cfg", - ".kokoro/samples/python3.7/common.cfg", - ".kokoro/samples/python3.7/continuous.cfg", - ".kokoro/samples/python3.7/periodic-head.cfg", - ".kokoro/samples/python3.7/periodic.cfg", - ".kokoro/samples/python3.7/presubmit.cfg", - ".kokoro/samples/python3.8/common.cfg", - ".kokoro/samples/python3.8/continuous.cfg", - ".kokoro/samples/python3.8/periodic-head.cfg", - ".kokoro/samples/python3.8/periodic.cfg", - ".kokoro/samples/python3.8/presubmit.cfg", - ".kokoro/test-samples-against-head.sh", - ".kokoro/test-samples-impl.sh", - ".kokoro/test-samples.sh", - ".kokoro/trampoline.sh", - ".kokoro/trampoline_v2.sh", - ".pre-commit-config.yaml", - ".trampolinerc", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.rst", - "LICENSE", - "MANIFEST.in", - "docs/_static/custom.css", - "docs/_templates/layout.html", - "docs/conf.py", - "docs/container_v1/cluster_manager.rst", - "docs/container_v1/services.rst", - "docs/container_v1/types.rst", - "docs/container_v1beta1/cluster_manager.rst", - "docs/container_v1beta1/services.rst", - "docs/container_v1beta1/types.rst", - "docs/multiprocessing.rst", - "google/cloud/container/__init__.py", - "google/cloud/container/py.typed", - "google/cloud/container_v1/__init__.py", - "google/cloud/container_v1/proto/cluster_service.proto", - "google/cloud/container_v1/py.typed", - "google/cloud/container_v1/services/__init__.py", - "google/cloud/container_v1/services/cluster_manager/__init__.py", - "google/cloud/container_v1/services/cluster_manager/async_client.py", - "google/cloud/container_v1/services/cluster_manager/client.py", - "google/cloud/container_v1/services/cluster_manager/pagers.py", - "google/cloud/container_v1/services/cluster_manager/transports/__init__.py", - "google/cloud/container_v1/services/cluster_manager/transports/base.py", - "google/cloud/container_v1/services/cluster_manager/transports/grpc.py", - "google/cloud/container_v1/services/cluster_manager/transports/grpc_asyncio.py", - "google/cloud/container_v1/types/__init__.py", - "google/cloud/container_v1/types/cluster_service.py", - "google/cloud/container_v1beta1/__init__.py", - "google/cloud/container_v1beta1/proto/cluster_service.proto", - "google/cloud/container_v1beta1/py.typed", - "google/cloud/container_v1beta1/services/__init__.py", - "google/cloud/container_v1beta1/services/cluster_manager/__init__.py", - "google/cloud/container_v1beta1/services/cluster_manager/async_client.py", - "google/cloud/container_v1beta1/services/cluster_manager/client.py", - "google/cloud/container_v1beta1/services/cluster_manager/pagers.py", - "google/cloud/container_v1beta1/services/cluster_manager/transports/__init__.py", - "google/cloud/container_v1beta1/services/cluster_manager/transports/base.py", - "google/cloud/container_v1beta1/services/cluster_manager/transports/grpc.py", - "google/cloud/container_v1beta1/services/cluster_manager/transports/grpc_asyncio.py", - "google/cloud/container_v1beta1/types/__init__.py", - "google/cloud/container_v1beta1/types/cluster_service.py", - "noxfile.py", - "renovate.json", - "samples/AUTHORING_GUIDE.md", - "samples/CONTRIBUTING.md", - "scripts/decrypt-secrets.sh", - "scripts/fixup_container_v1_keywords.py", - "scripts/fixup_container_v1beta1_keywords.py", - "scripts/readme-gen/readme_gen.py", - "scripts/readme-gen/templates/README.tmpl.rst", - "scripts/readme-gen/templates/auth.tmpl.rst", - "scripts/readme-gen/templates/auth_api_key.tmpl.rst", - "scripts/readme-gen/templates/install_deps.tmpl.rst", - "scripts/readme-gen/templates/install_portaudio.tmpl.rst", - "setup.cfg", - "testing/.gitignore", - "tests/unit/gapic/container_v1/__init__.py", - "tests/unit/gapic/container_v1/test_cluster_manager.py", - "tests/unit/gapic/container_v1beta1/__init__.py", - "tests/unit/gapic/container_v1beta1/test_cluster_manager.py" - ] -} \ No newline at end of file diff --git a/synth.py b/synth.py deleted file mode 100644 index 2ca4a663..00000000 --- a/synth.py +++ /dev/null @@ -1,111 +0,0 @@ -# Copyright 2018 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. - -"""This script is used to synthesize generated parts of this library.""" -import synthtool as s -from synthtool import gcp - -gapic = gcp.GAPICBazel() -common = gcp.CommonTemplates() -versions = ["v1beta1", "v1"] - -# ---------------------------------------------------------------------------- -# Generate container GAPIC layer -# ---------------------------------------------------------------------------- -for version in versions: - library = gapic.py_library( - service="container", - version=version, - bazel_target=f"//google/container/{version}:container-{version}-py", - include_protos=True, - proto_output_path=f"google/container_{version}/proto", - ) - - s.move(library / "google/container", "google/cloud/container") - s.move( - library / f"google/container_{version}", - f"google/cloud/container_{version}" - ) - s.move(library / "tests") - s.move(library / "scripts") - s.move(library / "docs", excludes=[library / "docs/index.rst"]) - - # Fix namespace - s.replace( - f"google/cloud/**/*.py", - f"google.container_{version}", - f"google.cloud.container_{version}", - ) - s.replace( - f"tests/unit/gapic/**/*.py", - f"google.container_{version}", - f"google.cloud.container_{version}", - ) - s.replace( - f"google/cloud/**/*.py", - f"google.container_{version}", - f"google.cloud.container_{version}", - ) - s.replace( - f"docs/**/*.rst", - f"google.container_{version}", - f"google.cloud.container_{version}", - ) - -# Fix package name -s.replace( - "google/cloud/**/*.py", - "google-container", - "google-cloud-container" -) - -# Issues exist where python files should define the source encoding -# https://github.com/googleapis/gapic-generator/issues/2097 -s.replace( - "google/**/proto/*_pb2.py", - r"(^.*$\n)*", - r"# -*- coding: utf-8 -*-\n\g<0>") - - -# Workaround https://github.com/googleapis/gapic-generator/issues/2449 -s.replace( - "google/**/proto/cluster_service_pb2.py", - r"nodePool>\n", - r"nodePool>`__\n", -) -s.replace( - "google/**/proto/cluster_service_pb2.py", - r"(\s+)`__ instead", - r"\g<1>instead", -) - -# ---------------------------------------------------------------------------- -# Add templated files -# ---------------------------------------------------------------------------- -templated_files = common.py_library( - samples=False, # set to True only if there are samples - microgenerator=True, - cov_level=99, -) -s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file - - -# TODO(busunkim): Use latest sphinx after microgenerator transition -s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') - -# Temporarily disable warnings due to -# https://github.com/googleapis/gapic-generator-python/issues/525 -s.replace("noxfile.py", '[\"\']-W[\"\']', '# "-W"') - -s.shell.run(["nox", "-s", "blacken"], hide_output=False)