Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for domain-scoped projects #185

Merged

Conversation

RahulDubey391
Copy link
Contributor

@RahulDubey391 RahulDubey391 commented Dec 18, 2023

Hi @jackwotherspoon , this is just an initial PR push, I'll be pushing more changes after testing them out. Meanwhile I have added a method for parsing the Instance URI. I got the opportunity to look into the Go Implementation for same issue. I have added the REGEX for the same.

Fixes #184

@RahulDubey391 RahulDubey391 changed the title Added _parse_instance_uri() feat: Added _parse_instance_uri() Dec 18, 2023
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

@RahulDubey391 I took a first pass on the PR, overall its like 80% of the way there 😄

Just need to update based on my suggestions and add tests similar to Python PR 👍

google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
Removed parse_instance_uri() as a class method and instead made it a standalone function. Added test case for the same function to check validity of URI.
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

@RahulDubey391 Awesome job on the updates! Couple small tweaks but mostly just adding that missing test for the bad instance URI 😄

google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
google/cloud/alloydb/connector/instance.py Outdated Show resolved Hide resolved
tests/unit/test_instance.py Outdated Show resolved Hide resolved
Added more tests for _parse_instance_uri(). Made the function private.
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

couple small nits otherwise LGTM

Comment on lines 81 to 87
(
self._project,
self._region,
self._cluster,
self._name,
) = _parse_instance_uri(instance_uri)

Copy link
Collaborator

Choose a reason for hiding this comment

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

is the linter adding the () around this tuple? I don't think we need them as the function can just unpack the tuple into the appropriate variables.

Suggested change
(
self._project,
self._region,
self._cluster,
self._name,
) = _parse_instance_uri(instance_uri)
self._project, self._region, self._cluster, self._name = _parse_instance_uri(instance_uri)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes @jackwotherspoon , the tuple was causing the formatting. I have removed it in the latest push.

),
],
)
def test_parse_instance_uri(instance_uri: str, expected: Tuple[str, str, str]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need the 4th str for the tuple...

Suggested change
def test_parse_instance_uri(instance_uri: str, expected: Tuple[str, str, str]) -> None:
def test_parse_instance_uri(instance_uri: str, expected: Tuple[str, str, str, str]) -> None:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad, I have added and pushed again with latest changes.

)
def test_parse_instance_uri(instance_uri: str, expected: Tuple[str, str, str]) -> None:
"""
Test that _parse_instance_uri correctly on
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Test that _parse_instance_uri correctly on
Test that _parse_instance_uri works correctly on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

again, my bad! I have added it.

@jackwotherspoon jackwotherspoon changed the title feat: Added _parse_instance_uri() feat: add support for domain-scoped projects Dec 20, 2023
Added missing str in Tuple. Also made changes for unpacking values for parser.
Copy link
Collaborator

@jackwotherspoon jackwotherspoon left a comment

Choose a reason for hiding this comment

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

This is an amazing contribution. Thanks so much @RahulDubey391 👏 🎉

@jackwotherspoon jackwotherspoon merged commit 59e10f1 into GoogleCloudPlatform:main Dec 21, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for domain-scoped projects
2 participants