Do not expose db passwords when pinging

This commit is contained in:
Einar Forselv 2019-12-05 00:38:58 +01:00
parent 9dabf01051
commit b9d5233510
2 changed files with 16 additions and 16 deletions

View File

@ -9,7 +9,7 @@ def test():
return run_command(['ls', '/volumes'])
def ping_mysql(host, port, username, password) -> int:
def ping_mysql(host, port, username) -> int:
"""Check if the mysql is up and can be reached"""
return run([
'mysqladmin',
@ -20,11 +20,10 @@ def ping_mysql(host, port, username, password) -> int:
port,
'--user',
username,
f'--password={password}',
])
def ping_mariadb(host, port, username, password) -> int:
def ping_mariadb(host, port, username): #, password) -> int:
"""Check if the mariadb is up and can be reached"""
return run([
'mysqladmin',
@ -35,7 +34,6 @@ def ping_mariadb(host, port, username, password) -> int:
port,
'--user',
username,
f'--password={password}',
])

View File

@ -22,12 +22,13 @@ class MariadbContainer(Container):
def ping(self) -> bool:
"""Check the availability of the service"""
creds = self.get_credentials()
return commands.ping_mysql(
creds['host'],
creds['port'],
creds['username'],
creds['password'],
)
with utils.environment('MYSQL_PWD', creds['password']):
return commands.ping_mariadb(
creds['host'],
creds['port'],
creds['username'],
)
def dump_command(self) -> list:
"""list: create a dump command restic and use to send data through stdin"""
@ -67,12 +68,13 @@ class MysqlContainer(Container):
def ping(self) -> bool:
"""Check the availability of the service"""
creds = self.get_credentials()
return commands.ping_mysql(
creds['host'],
creds['port'],
creds['username'],
creds['password'],
)
with utils.environment('MYSQL_PWD', creds['password']):
return commands.ping_mysql(
creds['host'],
creds['port'],
creds['username'],
)
def dump_command(self) -> list:
"""list: create a dump command restic and use to send data through stdin"""