Skip to content

Commit fb7ef70

Browse files
committed
Merge branch '16/edge' into sync14to16
2 parents 8d75c08 + 6fa983a commit fb7ef70

34 files changed

+3389
-3065
lines changed

actions.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,3 @@ restore:
9797
restore-to-time:
9898
type: string
9999
description: Point-in-time-recovery target in PSQL format.
100-
set-tls-private-key:
101-
description: Set the private key, which will be used for certificate signing requests (CSR). Run for each unit separately.
102-
params:
103-
private-key:
104-
type: string
105-
description: The content of private key for communications with clients. Content will be auto-generated if this option is not specified.

charmcraft.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ parts:
2424
# Use environment variable instead of `--break-system-packages` to avoid failing on older
2525
# versions of pip that do not recognize `--break-system-packages`
2626
# `--user` needed (in addition to `--break-system-packages`) for Ubuntu >=24.04
27-
PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==25.1 # renovate: charmcraft-pip-latest
27+
PIP_BREAK_SYSTEM_PACKAGES=true python3 -m pip install --user --upgrade pip==25.1.1 # renovate: charmcraft-pip-latest
2828
2929
# Use uv to install poetry so that a newer version of Python can be installed if needed by poetry
30-
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.6.17/uv-installer.sh | sh # renovate: charmcraft-uv-latest
30+
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.7.9/uv-installer.sh | sh # renovate: charmcraft-uv-latest
3131
# poetry 2.0.0 requires Python >=3.9
3232
if ! "$HOME/.local/bin/uv" python find '>=3.9'
3333
then
3434
# Use first Python version that is >=3.9 and available in an Ubuntu LTS
3535
# (to reduce the number of Python versions we use)
3636
"$HOME/.local/bin/uv" python install 3.10.12 # renovate: charmcraft-python-ubuntu-22.04
3737
fi
38-
"$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.1.2 --with poetry-plugin-export==1.9.0 # renovate: charmcraft-poetry-latest
38+
"$HOME/.local/bin/uv" tool install --no-python-downloads --python '>=3.9' poetry==2.1.3 --with poetry-plugin-export==1.9.0 # renovate: charmcraft-poetry-latest
3939
4040
ln -sf "$HOME/.local/bin/poetry" /usr/local/bin/poetry
4141
# "charm-poetry" part name is arbitrary; use for consistency
@@ -75,7 +75,7 @@ parts:
7575
# rpds-py (Python package) >=0.19.0 requires rustc >=1.76, which is not available in the
7676
# Ubuntu 22.04 archive. Install rustc and cargo using rustup instead of the Ubuntu archive
7777
rustup set profile minimal
78-
rustup default 1.86.0 # renovate: charmcraft-rust-latest
78+
rustup default 1.87.0 # renovate: charmcraft-rust-latest
7979
8080
craftctl default
8181
# Include requirements.txt in *.charm artifact for easier debugging

lib/charms/postgresql_k8s/v0/postgresql.py

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ def delete_user(self, user: str) -> None:
355355
# Existing objects need to be reassigned in each database
356356
# before the user can be deleted.
357357
for database in databases:
358-
with self._connect_to_database(
359-
database
360-
) as connection, connection.cursor() as cursor:
358+
with (
359+
self._connect_to_database(database) as connection,
360+
connection.cursor() as cursor,
361+
):
361362
cursor.execute(
362363
SQL("REASSIGN OWNED BY {} TO {};").format(
363364
Identifier(user), Identifier(self.user)
@@ -448,9 +449,10 @@ def enable_disable_extensions(
448449

449450
# Enable/disabled the extension in each database.
450451
for database in databases:
451-
with self._connect_to_database(
452-
database=database
453-
) as connection, connection.cursor() as cursor:
452+
with (
453+
self._connect_to_database(database=database) as connection,
454+
connection.cursor() as cursor,
455+
):
454456
for extension, enable in ordered_extensions.items():
455457
cursor.execute(
456458
f"CREATE EXTENSION IF NOT EXISTS {extension};"
@@ -560,9 +562,10 @@ def get_postgresql_text_search_configs(self) -> Set[str]:
560562
Returns:
561563
Set of PostgreSQL text search configs.
562564
"""
563-
with self._connect_to_database(
564-
database_host=self.current_host
565-
) as connection, connection.cursor() as cursor:
565+
with (
566+
self._connect_to_database(database_host=self.current_host) as connection,
567+
connection.cursor() as cursor,
568+
):
566569
cursor.execute("SELECT CONCAT('pg_catalog.', cfgname) FROM pg_ts_config;")
567570
text_search_configs = cursor.fetchall()
568571
return {text_search_config[0] for text_search_config in text_search_configs}
@@ -573,9 +576,10 @@ def get_postgresql_timezones(self) -> Set[str]:
573576
Returns:
574577
Set of PostgreSQL timezones.
575578
"""
576-
with self._connect_to_database(
577-
database_host=self.current_host
578-
) as connection, connection.cursor() as cursor:
579+
with (
580+
self._connect_to_database(database_host=self.current_host) as connection,
581+
connection.cursor() as cursor,
582+
):
579583
cursor.execute("SELECT name FROM pg_timezone_names;")
580584
timezones = cursor.fetchall()
581585
return {timezone[0] for timezone in timezones}
@@ -586,9 +590,10 @@ def get_postgresql_default_table_access_methods(self) -> Set[str]:
586590
Returns:
587591
Set of PostgreSQL table access methods.
588592
"""
589-
with self._connect_to_database(
590-
database_host=self.current_host
591-
) as connection, connection.cursor() as cursor:
593+
with (
594+
self._connect_to_database(database_host=self.current_host) as connection,
595+
connection.cursor() as cursor,
596+
):
592597
cursor.execute("SELECT amname FROM pg_am WHERE amtype = 't';")
593598
access_methods = cursor.fetchall()
594599
return {access_method[0] for access_method in access_methods}
@@ -601,9 +606,10 @@ def get_postgresql_version(self, current_host=True) -> str:
601606
"""
602607
host = self.current_host if current_host else None
603608
try:
604-
with self._connect_to_database(
605-
database_host=host
606-
) as connection, connection.cursor() as cursor:
609+
with (
610+
self._connect_to_database(database_host=host) as connection,
611+
connection.cursor() as cursor,
612+
):
607613
cursor.execute("SELECT version();")
608614
# Split to get only the version number.
609615
return cursor.fetchone()[0].split(" ")[1]
@@ -622,9 +628,12 @@ def is_tls_enabled(self, check_current_host: bool = False) -> bool:
622628
whether TLS is enabled.
623629
"""
624630
try:
625-
with self._connect_to_database(
626-
database_host=self.current_host if check_current_host else None
627-
) as connection, connection.cursor() as cursor:
631+
with (
632+
self._connect_to_database(
633+
database_host=self.current_host if check_current_host else None
634+
) as connection,
635+
connection.cursor() as cursor,
636+
):
628637
cursor.execute("SHOW ssl;")
629638
return "on" in cursor.fetchone()[0]
630639
except psycopg2.Error:
@@ -644,9 +653,10 @@ def list_access_groups(self, current_host=False) -> Set[str]:
644653
connection = None
645654
host = self.current_host if current_host else None
646655
try:
647-
with self._connect_to_database(
648-
database_host=host
649-
) as connection, connection.cursor() as cursor:
656+
with (
657+
self._connect_to_database(database_host=host) as connection,
658+
connection.cursor() as cursor,
659+
):
650660
cursor.execute(
651661
"SELECT groname FROM pg_catalog.pg_group WHERE groname LIKE '%_access';"
652662
)
@@ -674,9 +684,10 @@ def list_accessible_databases_for_user(self, user: str, current_host=False) -> S
674684
connection = None
675685
host = self.current_host if current_host else None
676686
try:
677-
with self._connect_to_database(
678-
database_host=host
679-
) as connection, connection.cursor() as cursor:
687+
with (
688+
self._connect_to_database(database_host=host) as connection,
689+
connection.cursor() as cursor,
690+
):
680691
cursor.execute(
681692
SQL(
682693
"SELECT TRUE FROM pg_catalog.pg_user WHERE usename = {} AND usesuper;"
@@ -712,9 +723,10 @@ def list_users(self, group: Optional[str] = None, current_host=False) -> Set[str
712723
connection = None
713724
host = self.current_host if current_host else None
714725
try:
715-
with self._connect_to_database(
716-
database_host=host
717-
) as connection, connection.cursor() as cursor:
726+
with (
727+
self._connect_to_database(database_host=host) as connection,
728+
connection.cursor() as cursor,
729+
):
718730
if group:
719731
query = SQL(
720732
"SELECT usename FROM (SELECT UNNEST(grolist) AS user_id FROM pg_catalog.pg_group WHERE groname = {}) AS g JOIN pg_catalog.pg_user AS u ON g.user_id = u.usesysid;"
@@ -744,9 +756,10 @@ def list_users_from_relation(self, current_host=False) -> Set[str]:
744756
connection = None
745757
host = self.current_host if current_host else None
746758
try:
747-
with self._connect_to_database(
748-
database_host=host
749-
) as connection, connection.cursor() as cursor:
759+
with (
760+
self._connect_to_database(database_host=host) as connection,
761+
connection.cursor() as cursor,
762+
):
750763
cursor.execute(
751764
"SELECT usename "
752765
"FROM pg_catalog.pg_user "
@@ -782,9 +795,10 @@ def set_up_database(self, temp_location: Optional[str] = None) -> None:
782795
connection = None
783796
cursor = None
784797
try:
785-
with self._connect_to_database(
786-
database="template1"
787-
) as connection, connection.cursor() as cursor:
798+
with (
799+
self._connect_to_database(database="template1") as connection,
800+
connection.cursor() as cursor,
801+
):
788802
# Create database function and event trigger to identify users created by PgBouncer.
789803
cursor.execute(
790804
"SELECT TRUE FROM pg_event_trigger WHERE evtname = 'update_pg_hba_on_create_schema';"
@@ -900,9 +914,10 @@ def update_user_password(
900914
"""
901915
connection = None
902916
try:
903-
with self._connect_to_database(
904-
database_host=database_host
905-
) as connection, connection.cursor() as cursor:
917+
with (
918+
self._connect_to_database(database_host=database_host) as connection,
919+
connection.cursor() as cursor,
920+
):
906921
cursor.execute(SQL("BEGIN;"))
907922
cursor.execute(SQL("SET LOCAL log_statement = 'none';"))
908923
cursor.execute(
@@ -1039,9 +1054,10 @@ def validate_date_style(self, date_style: str) -> bool:
10391054
Whether the date style is valid.
10401055
"""
10411056
try:
1042-
with self._connect_to_database(
1043-
database_host=self.current_host
1044-
) as connection, connection.cursor() as cursor:
1057+
with (
1058+
self._connect_to_database(database_host=self.current_host) as connection,
1059+
connection.cursor() as cursor,
1060+
):
10451061
cursor.execute(
10461062
SQL(
10471063
"SET DateStyle to {};",

0 commit comments

Comments
 (0)