Skip to content

Commit

Permalink
Merge pull request #396 from aiven/mysql-cli-client
Browse files Browse the repository at this point in the history
Add MySQL client support for "avn service cli" cmd
  • Loading branch information
bugant authored Jan 13, 2025
2 parents e73ee16 + 7b5a211 commit a1c1eeb
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions aiven/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1607,6 +1607,8 @@ def service__cli(self) -> None:
command, params, env = self._build_psql_start_info(url)
elif service_type == "rediss":
command, params, env = self._build_redis_start_info(url)
elif service_type == "mysql":
command, params, env = self._build_mysql_start_info(url)
else:
raise argx.UserError(
"Unsupported service type {}. Only InfluxDB, PostgreSQL, and Redis are supported".format(service_type)
Expand Down Expand Up @@ -1640,6 +1642,18 @@ def _build_psql_start_info(self, url: str) -> tuple[str, list, Mapping]:
connect_info = re.sub(pw_pattern, "\\1@\\3", url)
return "psql", [connect_info], {"PGPASSWORD": match.group(2) if match else None}

def _build_mysql_start_info(self, url: str) -> tuple[str, list, Mapping]:
info = urlparse(url)
params = [
"-h",
info.hostname,
"-P",
str(info.port),
"-u",
info.username,
]
return "mysql", params, {"MYSQL_PWD": info.password}

def _build_redis_start_info(self, url: str) -> tuple[str, list, Mapping]:
info = urlparse(url)
params = [
Expand Down

0 comments on commit a1c1eeb

Please # to comment.