-
Notifications
You must be signed in to change notification settings - Fork 4
jir-ogc #555
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
jir-ogc #555
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,7 +120,6 @@ def run_migrations_online() -> None: | |
|
|
||
| instance_name = os.environ.get("CLOUD_SQL_INSTANCE_NAME") | ||
| user = os.environ.get("CLOUD_SQL_USER") | ||
| password = os.environ.get("CLOUD_SQL_PASSWORD") | ||
| database = os.environ.get("CLOUD_SQL_DATABASE") | ||
| use_iam_auth = get_bool_env("CLOUD_SQL_IAM_AUTH", True) | ||
| ip_type = os.environ.get("CLOUD_SQL_IP_TYPE", "public") | ||
|
|
@@ -147,10 +146,11 @@ def getconn(): | |
| "ip_type": ip_type, | ||
| "enable_iam_auth": use_iam_auth, | ||
| } | ||
| if use_iam_auth: | ||
| connect_kwargs["password"] = get_iam_login_token() | ||
| else: | ||
| connect_kwargs["password"] = password | ||
| if not use_iam_auth: | ||
| raise RuntimeError( | ||
|
Comment on lines
+149
to
+150
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| "CLOUD_SQL_IAM_AUTH must be true when DB_DRIVER=cloudsql." | ||
| ) | ||
|
Comment on lines
+149
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The migration connector now hard-fails when Useful? React with 👍 / 👎. |
||
| connect_kwargs["password"] = get_iam_login_token() | ||
| return connector.connect( | ||
| instance_name, | ||
| "pg8000", | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -69,7 +69,6 @@ def asyncify_connection(): | |||||
|
|
||||||
| instance_name = os.environ.get("CLOUD_SQL_INSTANCE_NAME") | ||||||
| user = os.environ.get("CLOUD_SQL_USER") | ||||||
| password = os.environ.get("CLOUD_SQL_PASSWORD") | ||||||
| database = os.environ.get("CLOUD_SQL_DATABASE") | ||||||
| use_iam_auth = get_bool_env("CLOUD_SQL_IAM_AUTH", True) | ||||||
| ip_type = os.environ.get("CLOUD_SQL_IP_TYPE", "public") | ||||||
|
|
@@ -80,10 +79,11 @@ def asyncify_connection(): | |||||
| "enable_iam_auth": use_iam_auth, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the code now enforces that IAM auth must be enabled (raising an error if it's not), the
Suggested change
|
||||||
| "ip_type": ip_type, | ||||||
| } | ||||||
| if use_iam_auth: | ||||||
| connect_kwargs["password"] = get_iam_login_token() | ||||||
| else: | ||||||
| connect_kwargs["password"] = password | ||||||
| if not use_iam_auth: | ||||||
| raise RuntimeError( | ||||||
| "CLOUD_SQL_IAM_AUTH must be true when DB_DRIVER=cloudsql." | ||||||
| ) | ||||||
|
Comment on lines
+82
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This branch now throws whenever Useful? React with 👍 / 👎. |
||||||
| connect_kwargs["password"] = get_iam_login_token() | ||||||
|
|
||||||
| connection = connector.connect_async(instance_name, "asyncpg", **connect_kwargs) | ||||||
|
|
||||||
|
|
@@ -106,7 +106,6 @@ def asyncify_connection(): | |||||
| def init_connection_pool(connector): | ||||||
| instance_name = os.environ.get("CLOUD_SQL_INSTANCE_NAME") | ||||||
| user = os.environ.get("CLOUD_SQL_USER") | ||||||
| password = os.environ.get("CLOUD_SQL_PASSWORD") | ||||||
| database = os.environ.get("CLOUD_SQL_DATABASE") | ||||||
| use_iam_auth = get_bool_env("CLOUD_SQL_IAM_AUTH", True) | ||||||
| ip_type = os.environ.get("CLOUD_SQL_IP_TYPE", "public") | ||||||
|
|
@@ -118,10 +117,11 @@ def getconn(): | |||||
| "ip_type": ip_type, | ||||||
| "enable_iam_auth": use_iam_auth, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the code now enforces that IAM auth must be enabled (raising an error if it's not), the |
||||||
| } | ||||||
| if use_iam_auth: | ||||||
| connect_kwargs["password"] = get_iam_login_token() | ||||||
| else: | ||||||
| connect_kwargs["password"] = password | ||||||
| if not use_iam_auth: | ||||||
| raise RuntimeError( | ||||||
|
Comment on lines
+120
to
+121
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||||||
| "CLOUD_SQL_IAM_AUTH must be true when DB_DRIVER=cloudsql." | ||||||
| ) | ||||||
| connect_kwargs["password"] = get_iam_login_token() | ||||||
|
|
||||||
| conn = connector.connect( | ||||||
| instance_name, # The Cloud SQL instance name | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the code now enforces that IAM auth must be enabled (raising an error if it's not), the
enable_iam_authparameter inconnect_kwargsshould be hardcoded toTrueinstead of using theuse_iam_authvariable. This makes the intent clearer and avoids passing a value that's alwaysTrueat this point in the code.