Skip to content

Commit 0269cb2

Browse files
committed
fix: add proper type to hosts in haproxy libraries
1 parent a3f5bea commit 0269cb2

4 files changed

Lines changed: 26 additions & 9 deletions

File tree

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
88

99
Each revision is versioned by the date of the revision.
1010

11+
## 2026-03-23
12+
13+
- Fixed hosts validation in haproxy-route and haproxy-route-tcp relation libraries.
14+
1115
## 2026-01-19
1216

1317
- Fixed issues with the DDoS protection configurator charm found in staging.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version_schema: 2
2+
changes:
3+
- title: Fix hosts validation in haproxy-route-tcp, and haproxy-route relation libraries
4+
author: skatsaounis
5+
type: bugfix
6+
description: >
7+
Fixed hosts validation in the haproxy-route-tcp and haproxy-route relation libraries, ensuring
8+
that only valid IP addresses are accepted.
9+
urls:
10+
pr:
11+
- https://github.com/canonical/haproxy-operator/pull/383
12+
visibility: public
13+
highlight: false

haproxy-operator/lib/charms/haproxy/v1/haproxy_route_tcp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _on_haproxy_route_data_available(self, event: EventBase) -> None:
186186

187187
# Increment this PATCH version before using `charmcraft publish-lib` or reset
188188
# to 0 if you are raising the major API version
189-
LIBPATCH = 1
189+
LIBPATCH = 2
190190

191191
logger = logging.getLogger(__name__)
192192
HAPROXY_ROUTE_TCP_RELATION_NAME = "haproxy-route-tcp"
@@ -976,7 +976,7 @@ def __init__(
976976
*,
977977
port: Optional[int] = None,
978978
backend_port: Optional[int] = None,
979-
hosts: Optional[list[str]] = None,
979+
hosts: Optional[list[IPvAnyAddress]] = None,
980980
sni: Optional[str] = None,
981981
check_interval: Optional[int] = None,
982982
check_rise: Optional[int] = None,
@@ -1102,7 +1102,7 @@ def provide_haproxy_route_tcp_requirements(
11021102
*,
11031103
port: int,
11041104
backend_port: Optional[int] = None,
1105-
hosts: Optional[list[str]] = None,
1105+
hosts: Optional[list[IPvAnyAddress]] = None,
11061106
sni: Optional[str] = None,
11071107
check_interval: Optional[int] = None,
11081108
check_rise: Optional[int] = None,
@@ -1200,7 +1200,7 @@ def _generate_application_data(
12001200
*,
12011201
port: Optional[int] = None,
12021202
backend_port: Optional[int] = None,
1203-
hosts: Optional[list[str]] = None,
1203+
hosts: Optional[list[IPvAnyAddress]] = None,
12041204
sni: Optional[str] = None,
12051205
check_interval: Optional[int] = None,
12061206
check_rise: Optional[int] = None,
@@ -1558,7 +1558,7 @@ def configure_backend_port(self, backend_port: int) -> "Self":
15581558
self._application_data["backend_port"] = backend_port
15591559
return self
15601560

1561-
def configure_hosts(self, hosts: Optional[list[int]] = None) -> "Self":
1561+
def configure_hosts(self, hosts: Optional[list[IPvAnyAddress]] = None) -> "Self":
15621562
"""Set backend hosts.
15631563
15641564
Args:

haproxy-operator/lib/charms/haproxy/v2/haproxy_route.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def _on_haproxy_route_data_available(self, event: EventBase) -> None:
154154

155155
# Increment this PATCH version before using `charmcraft publish-lib` or reset
156156
# to 0 if you are raising the major API version
157-
LIBPATCH = 0
157+
LIBPATCH = 1
158158

159159
logger = logging.getLogger(__name__)
160160
HAPROXY_ROUTE_RELATION_NAME = "haproxy-route"
@@ -1005,7 +1005,7 @@ def __init__(
10051005
service: Optional[str] = None,
10061006
ports: Optional[list[int]] = None,
10071007
protocol: Literal["http", "https"] = "http",
1008-
hosts: Optional[list[str]] = None,
1008+
hosts: Optional[list[IPvAnyAddress]] = None,
10091009
paths: Optional[list[str]] = None,
10101010
hostname: Optional[str] = None,
10111011
additional_hostnames: Optional[list[str]] = None,
@@ -1144,7 +1144,7 @@ def provide_haproxy_route_requirements(
11441144
service: str,
11451145
ports: list[int],
11461146
protocol: Literal["http", "https"] = "http",
1147-
hosts: Optional[list[str]] = None,
1147+
hosts: Optional[list[IPvAnyAddress]] = None,
11481148
paths: Optional[list[str]] = None,
11491149
hostname: Optional[str] = None,
11501150
additional_hostnames: Optional[list[str]] = None,
@@ -1258,7 +1258,7 @@ def _generate_application_data( # noqa: C901
12581258
service: Optional[str] = None,
12591259
ports: Optional[list[int]] = None,
12601260
protocol: Literal["http", "https"] = "http",
1261-
hosts: Optional[list[str]] = None,
1261+
hosts: Optional[list[IPvAnyAddress]] = None,
12621262
paths: Optional[list[str]] = None,
12631263
hostname: Optional[str] = None,
12641264
additional_hostnames: Optional[list[str]] = None,

0 commit comments

Comments
 (0)