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

chore: prepare for monorepo migration #296

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ branch = True
[report]
show_missing = True
omit =
google/cloud/iam_credentials/__init__.py
google/cloud/iam_credentials/gapic_version.py
google/cloud/iam/__init__.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im Java iam and iamcredentials are different library. If this change is intentional, that's fine.

Copy link
Contributor Author

@parthea parthea Aug 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. iamcredentials was shipped first as google-cloud-iam instead of google-cloud-iamcredentials. I think this is what caused us to merge the 2 APIs. When google/iam v2/v2beta came along we decided to add them to the existing google-cloud-iam package. We don't have plans to split up iam and iamcredentials. Let's continue the discussion in googleapis/google-cloud-python#11572 which mentions consolidating iam APIs.

google/cloud/iam/gapic_version.py
exclude_lines =
# Re-enable the standard pragma
pragma: NO COVER
Expand Down
4 changes: 2 additions & 2 deletions .github/.OwlBot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ deep-preserve-regex:

deep-copy-regex:
- source: /google/iam/credentials/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/iamcredentials/$1/$2
dest: /owl-bot-staging/$1/$2
- source: /google/iam/(v.*)/.*-py/(.*)
dest: /owl-bot-staging/iam/$1/$2
dest: /owl-bot-staging/$1/$2

begin-after-commit-hash: 130ce904e5d546c312943d10f48799590f9c0f66

2 changes: 1 addition & 1 deletion .repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"repo": "googleapis/python-iam",
"distribution_name": "google-cloud-iam",
"api_id": "iam.googleapis.com",
"default_version": "v1",
"default_version": "v2",
"codeowner_team": "",
"api_shortname": "iamcredentials"
}
4 changes: 4 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

.. include:: multiprocessing.rst

This package includes clients for multiple versions of Cloud Identity and Access Management.
By default, you will get version ``iam_v2``.


API Reference
-------------
Expand All @@ -27,6 +30,7 @@ API Reference
iam_v2beta/services
iam_v2beta/types


Migration Guide
---------------

Expand Down
58 changes: 7 additions & 51 deletions owlbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

import json
from pathlib import Path
from typing import List, Optional

import shutil

import synthtool as s
Expand All @@ -28,58 +26,16 @@

clean_up_generated_samples = True

# This is a customized version of the s.get_staging_dirs() function from synthtool to
# cater for copying 2 different folders from googleapis-gen
# which are workflows and workflows/executions
# Source https://github.com/googleapis/synthtool/blob/master/synthtool/transforms.py#L280
def get_staging_dirs(
default_version: Optional[str] = None, sub_directory: Optional[str] = None
) -> List[Path]:
"""Returns the list of directories, one per version, copied from
https://github.com/googleapis/googleapis-gen. Will return in lexical sorting
order with the exception of the default_version which will be last (if specified).
Args:
default_version (str): the default version of the API. The directory for this version
will be the last item in the returned list if specified.
sub_directory (str): if a `sub_directory` is provided, only the directories within the
specified `sub_directory` will be returned.
Returns: the empty list if no file were copied.
"""

staging = Path("owl-bot-staging")

if sub_directory:
staging /= sub_directory

if staging.is_dir():
# Collect the subdirectories of the staging directory.
versions = [v.name for v in staging.iterdir() if v.is_dir()]
# Reorder the versions so the default version always comes last.
versions = [v for v in versions if v != default_version]
versions.sort()
if default_version is not None:
versions += [default_version]
dirs = [staging / v for v in versions]
for dir in dirs:
s._tracked_paths.add(dir)
return dirs
else:
return []

# This library ships clients for two different APIs,
# IAM and IAM credentials
iam_credentials_default_version = "v1"
iam_default_version = "v2"
# Load the default version defined in .repo-metadata.json.
default_version = json.load(open(".repo-metadata.json", "rt")).get(
"default_version"
)

for library in get_staging_dirs(iam_default_version, "iam"):
for library in s.get_staging_dirs(default_version):
if clean_up_generated_samples:
shutil.rmtree("samples/generated_samples", ignore_errors=True)
clean_up_generated_samples = False
s.move([library], excludes=["docs/index.rst", "**/gapic_version.py"])

for library in get_staging_dirs(iam_credentials_default_version, "iamcredentials"):
s.move([library], excludes=["setup.py", "docs/index.rst", "**/gapic_version.py"])

s.move([library], excludes=["**/gapic_version.py"])
s.remove_staging_dirs()

# ----------------------------------------------------------------------------
Expand All @@ -91,7 +47,7 @@ def get_staging_dirs(
microgenerator=True,
versions=gcp.common.detect_versions(path="./google", default_first=True),
)
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "docs/index.rst"])
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"])

python.py_samples(skip_readmes=True)

Expand Down