Skip to content

Commit

Permalink
{db-up} Fix Azure#3143: db-up does not return correct PostgreSQL host…
Browse files Browse the repository at this point in the history
… for Azure Government (Azure#3174)

* test pass

* fix style
  • Loading branch information
Juliehzl authored Mar 23, 2021
1 parent 97f2afc commit 2632452
Show file tree
Hide file tree
Showing 6 changed files with 1,086 additions and 824 deletions.
4 changes: 4 additions & 0 deletions src/db-up/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Release History
===============

0.2.2 (2021-03-22)
++++++++++++++++++
* Configure for custom cloud settings

0.2.1 (2021-01-11)
++++++++++++++++++
* Bump mysql-connector-python to 8.0.14 to fix CVE-2019-2435
Expand Down
21 changes: 9 additions & 12 deletions src/db-up/azext_db_up/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,33 +229,30 @@ def server_down(cmd, client, resource_group_name=None, server_name=None, delete_
return client.delete(resource_group_name, server_name)


def create_mysql_connection_string(
server_name='{server}', database_name='{database}', administrator_login='{login}',
administrator_login_password='{password}'):
def create_mysql_connection_string(cmd, server_name='{server}', database_name='{database}',
administrator_login='{login}', administrator_login_password='{password}'):
user = '{}@{}'.format(administrator_login, server_name)
host = '{}.mysql.database.azure.com'.format(server_name)
host = server_name + cmd.cli_ctx.cloud.suffixes.mysql_server_endpoint
return _form_response(
_create_mysql_connection_string(host, user, administrator_login_password, database_name),
host, user, administrator_login_password
)


def create_postgresql_connection_string(
server_name='{server}', database_name='{database}', administrator_login='{login}',
administrator_login_password='{password}'):
def create_postgresql_connection_string(cmd, server_name='{server}', database_name='{database}',
administrator_login='{login}', administrator_login_password='{password}'):
user = '{}@{}'.format(administrator_login, server_name)
host = '{}.postgres.database.azure.com'.format(server_name)
host = server_name + cmd.cli_ctx.cloud.suffixes.postgresql_server_endpoint
return _form_response(
_create_postgresql_connection_string(host, user, administrator_login_password, database_name),
host, user, administrator_login_password
)


def create_sql_connection_string(
server_name='{server}', database_name='{database}', administrator_login='{login}',
administrator_login_password='{password}'):
def create_sql_connection_string(cmd, server_name='{server}', database_name='{database}', administrator_login='{login}',
administrator_login_password='{password}'):
user = '{}@{}'.format(administrator_login, server_name)
host = '{}.database.windows.net'.format(server_name)
host = server_name + cmd.cli_ctx.cloud.suffixes.sql_server_endpoint
return _form_response(
_create_sql_connection_string(host, user, administrator_login_password, database_name),
host, user, administrator_login_password
Expand Down
Loading

0 comments on commit 2632452

Please sign in to comment.