Skip to content

Commit 9ca39cc

Browse files
feat: add K8s locale superset to single kernel (#149)
The K8s rock ships C.utf8 and POSIX (from the base image's libc-bin) that the VM snap's locales-all omits, so #137's single SNAP_LOCALES rejects those otherwise-valid values for the K8s response-lc-* config. Add K8S_LOCALES extending SNAP_LOCALES with the two rock-only entries so the K8s config model can accept them while VM keeps the snap-only set. Signed-off-by: Marcelo Henrique Neppel <marcelo.neppel@canonical.com>
1 parent a562198 commit 9ca39cc

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

single_kernel_postgresql/config/locales.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# Copyright 2024 Canonical Ltd.
22
# See LICENSE file for licensing details.
33

4-
"""List of locales available in the snap."""
4+
"""Locales accepted by the PostgreSQL ``response_lc_*`` config options.
5+
6+
``SNAP_LOCALES`` is the set the VM snap ships (it stages ``locales-all``). The
7+
K8s rock additionally ships ``C.utf8`` and ``POSIX`` (from the Ubuntu base's
8+
``libc-bin``), so ``K8S_LOCALES`` extends ``SNAP_LOCALES`` with those two.
9+
"""
510

611
from typing import Literal
712

@@ -516,3 +521,7 @@
516521
"zu_ZA",
517522
"zu_ZA.utf8",
518523
]
524+
525+
526+
# The K8s rock additionally ships these (from libc-bin); the VM snap does not.
527+
K8S_LOCALES = Literal[SNAP_LOCALES, "C.utf8", "POSIX"]

tests/unit/test_locales.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2026 Canonical Ltd.
2+
# See LICENSE file for licensing details.
3+
from typing import get_args
4+
5+
from single_kernel_postgresql.config.locales import K8S_LOCALES, SNAP_LOCALES
6+
7+
8+
def test_snap_locales_exclude_k8s_only_entries():
9+
members = get_args(SNAP_LOCALES)
10+
assert "C" in members
11+
assert "C.utf8" not in members
12+
assert "POSIX" not in members
13+
14+
15+
def test_k8s_locales_extend_snap_with_rock_only_entries():
16+
snap = set(get_args(SNAP_LOCALES))
17+
k8s = set(get_args(K8S_LOCALES))
18+
assert k8s - snap == {"C.utf8", "POSIX"}
19+
assert snap - k8s == set()

0 commit comments

Comments
 (0)