Skip to content

Commit 4ee76a5

Browse files
committed
client: add support for Valkey connection info
1 parent 9acc700 commit 4ee76a5

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

aiven/client/cli.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from aiven.client.connection_info.common import Store
1313
from aiven.client.connection_info.kafka import KafkaCertificateConnectionInfo, KafkaSASLConnectionInfo
1414
from aiven.client.connection_info.pg import PGConnectionInfo
15-
from aiven.client.connection_info.redis import RedisConnectionInfo
15+
from aiven.client.connection_info.valkey import ValkeyConnectionInfo
1616
from aiven.client.speller import suggest
1717
from argparse import ArgumentParser
1818
from ast import literal_eval
@@ -1578,11 +1578,11 @@ def service__connection_info__alloydbomni__string(self) -> None:
15781578
@arg("--replica", action="store_true")
15791579
@arg("-u", "--username", default="default")
15801580
@arg("-d", "--db")
1581-
def service__connection_info__redis__uri(self) -> None:
1582-
"""Redis connection string"""
1581+
def service__connection_info__valkey__uri(self) -> None:
1582+
"""Valkey connection string"""
15831583
service = self.client.get_service(project=self.get_project(), service=self.args.service_name)
15841584

1585-
ci = RedisConnectionInfo.from_service(
1585+
ci = ValkeyConnectionInfo.from_service(
15861586
service,
15871587
route=self._get_route_from_args(),
15881588
usage=self._get_usage_from_args(),
@@ -1617,13 +1617,15 @@ def service__cli(self) -> None:
16171617
command, params, env = self._build_influx_start_info(url)
16181618
elif service_type == "postgres":
16191619
command, params, env = self._build_psql_start_info(url)
1620-
elif service_type == "rediss":
1621-
command, params, env = self._build_redis_start_info(url)
1620+
elif service_type == "valkey":
1621+
command, params, env = self._build_valkey_start_info(url)
16221622
elif service_type == "mysql":
16231623
command, params, env = self._build_mysql_start_info(url)
16241624
else:
16251625
raise argx.UserError(
1626-
"Unsupported service type {}. Only InfluxDB, PostgreSQL, and Redis are supported".format(service_type)
1626+
"Unsupported service type {}. Only InfluxDB, PostgreSQL, MySQL, and Valkey are supported".format(
1627+
service_type
1628+
)
16271629
)
16281630

16291631
try:
@@ -1666,7 +1668,7 @@ def _build_mysql_start_info(self, url: str) -> tuple[str, list, Mapping]:
16661668
]
16671669
return "mysql", params, {"MYSQL_PWD": info.password}
16681670

1669-
def _build_redis_start_info(self, url: str) -> tuple[str, list, Mapping]:
1671+
def _build_valkey_start_info(self, url: str) -> tuple[str, list, Mapping]:
16701672
info = urlparse(url)
16711673
params = [
16721674
"--tls",
@@ -1677,7 +1679,7 @@ def _build_redis_start_info(self, url: str) -> tuple[str, list, Mapping]:
16771679
"--user",
16781680
info.username,
16791681
]
1680-
return "redis-cli", params, {"REDISCLI_AUTH": info.password}
1682+
return "valkey-cli", params, {"VALKEYCLI_AUTH": info.password}
16811683

16821684
@arg.project
16831685
@arg.service_name

aiven/client/connection_info/redis.py renamed to aiven/client/connection_info/valkey.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
@dataclass
12-
class RedisConnectionInfo:
12+
class ValkeyConnectionInfo:
1313
host: str
1414
port: int
1515
username: str
@@ -26,10 +26,10 @@ def from_service(
2626
privatelink_connection_id: object | str,
2727
username: str,
2828
db: str,
29-
) -> RedisConnectionInfo:
30-
if service["service_type"] != "redis":
29+
) -> ValkeyConnectionInfo:
30+
if service["service_type"] != "valkey":
3131
raise ConnectionInfoError(
32-
"Cannot format redis connection info for service type {service_type}".format_map(service)
32+
"Cannot format Valkey connection info for service type {service_type}".format_map(service)
3333
)
3434

3535
info = find_component(
@@ -38,7 +38,7 @@ def from_service(
3838
host = info["host"]
3939
port = info["port"]
4040
if username == "default":
41-
password = service["connection_info"]["redis_password"]
41+
password = service["connection_info"]["valkey_password"]
4242
else:
4343
user = find_user(service, username)
4444
password = user.get("password")

tests/test_pretty.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,10 @@ def test_yield_table() -> None:
200200
},
201201
{
202202
"access_control": {
203-
"redis_acl_categories": ["+@all"],
204-
"redis_acl_channels": ["*"],
205-
"redis_acl_commands": ["+get", "-set"],
206-
"redis_acl_keys": ["key1", "key2"],
203+
"valkey_acl_categories": ["+@all"],
204+
"valkey_acl_channels": ["*"],
205+
"valkey_acl_commands": ["+get", "-set"],
206+
"valkey_acl_keys": ["key1", "key2"],
207207
},
208208
"password": "qwertyuiop",
209209
"type": "regular",
@@ -220,18 +220,18 @@ def test_yield_table() -> None:
220220
"myuser regular",
221221
]
222222

223-
one_row_layout_redis = [["username", "type", "access_control.redis_acl_keys"]]
224-
result = yield_table(rows, table_layout=one_row_layout_redis)
223+
one_row_layout_valkey = [["username", "type", "access_control.valkey_acl_keys"]]
224+
result = yield_table(rows, table_layout=one_row_layout_valkey)
225225
assert list(result) == [
226-
"USERNAME TYPE ACCESS_CONTROL.REDIS_ACL_KEYS",
227-
"======== ======= =============================",
226+
"USERNAME TYPE ACCESS_CONTROL.VALKEY_ACL_KEYS",
227+
"======== ======= ==============================",
228228
"avnadmin primary",
229229
"myuser regular key1, key2",
230230
]
231231

232232
vertical_layout_both: TableLayout = [
233233
["username", "type"],
234-
"access_control.redis_acl_keys",
234+
"access_control.valkey_acl_keys",
235235
"access_control.pg_allow_replication",
236236
]
237237
result = yield_table(rows, table_layout=vertical_layout_both)
@@ -242,5 +242,5 @@ def test_yield_table() -> None:
242242
" access_control.pg_allow_replication = true",
243243
"",
244244
"myuser regular",
245-
" access_control.redis_acl_keys = key1, key2",
245+
" access_control.valkey_acl_keys = key1, key2",
246246
]

tests/test_speller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"m3aggregator",
2525
"mysql",
2626
"pg",
27-
"redis",
27+
"valkey",
2828
"sw",
2929
"flink",
3030
]

0 commit comments

Comments
 (0)