Skip to content

Commit 489cc18

Browse files
committed
added section_name parameter to all policy creation functions.
Signed-off-by: Martin Hesko <[email protected]>
1 parent f47d53f commit 489cc18

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

testsuite/kuadrant/policy/authorization/auth_policy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def create_instance(
2727
name,
2828
target: Referencable,
2929
labels: Dict[str, str] = None,
30+
section_name: str = None,
3031
):
3132
"""Creates base instance"""
3233
model: Dict = {
@@ -37,6 +38,8 @@ def create_instance(
3738
"targetRef": target.reference,
3839
},
3940
}
41+
if section_name:
42+
model["spec"]["targetRef"]["sectionName"] = section_name
4043

4144
return cls(model, context=cluster.context)
4245

testsuite/kuadrant/policy/dns.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def create_instance(
6969
name: str,
7070
parent: Referencable,
7171
provider_secret_name: str,
72+
section_name: str = None,
7273
load_balancing: LoadBalancing = None,
7374
labels: dict[str, str] = None,
7475
):
@@ -86,6 +87,8 @@ def create_instance(
8687

8788
if load_balancing:
8889
model["spec"]["loadBalancing"] = asdict(load_balancing)
90+
if section_name:
91+
model["spec"]["targetRef"]["sectionName"] = section_name
8992

9093
return cls(model, context=cluster.context)
9194

testsuite/kuadrant/policy/rate_limit.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,25 @@ def __init__(self, *args, **kwargs):
2727
self.spec_section = None
2828

2929
@classmethod
30-
def create_instance(cls, cluster: KubernetesClient, name, target: Referencable, labels: dict[str, str] = None):
30+
def create_instance(
31+
cls,
32+
cluster: KubernetesClient,
33+
name,
34+
target: Referencable,
35+
section_name: str = None,
36+
labels: dict[str, str] = None,
37+
):
3138
"""Creates new instance of RateLimitPolicy"""
32-
model = {
39+
model: dict = {
3340
"apiVersion": "kuadrant.io/v1",
3441
"kind": "RateLimitPolicy",
3542
"metadata": {"name": name, "labels": labels},
3643
"spec": {
3744
"targetRef": target.reference,
3845
},
3946
}
47+
if section_name:
48+
model["spec"]["targetRef"]["sectionName"] = section_name
4049

4150
return cls(model, context=cluster.context)
4251

testsuite/kuadrant/policy/tls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def create_instance(
1515
name: str,
1616
parent: Referencable,
1717
issuer: Referencable,
18+
section_name: str = None,
1819
labels: dict[str, str] = None,
1920
commonName: str = None,
2021
duration: str = None,
@@ -24,7 +25,7 @@ def create_instance(
2425
): # pylint: disable=invalid-name
2526
"""Creates new instance of TLSPolicy"""
2627

27-
model = {
28+
model: dict = {
2829
"apiVersion": "kuadrant.io/v1",
2930
"kind": "TLSPolicy",
3031
"metadata": {"name": name, "labels": labels},
@@ -40,6 +41,8 @@ def create_instance(
4041
},
4142
},
4243
}
44+
if section_name:
45+
model["spec"]["targetRef"]["sectionName"] = section_name
4346

4447
return cls(model, context=cluster.context)
4548

0 commit comments

Comments
 (0)