Skip to content

Commit

Permalink
added section_name parameter to all policy creation functions.
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Hesko <[email protected]>
  • Loading branch information
martinhesko committed Nov 20, 2024
1 parent f47d53f commit 489cc18
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions testsuite/kuadrant/policy/authorization/auth_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def create_instance(
name,
target: Referencable,
labels: Dict[str, str] = None,
section_name: str = None,
):
"""Creates base instance"""
model: Dict = {
Expand All @@ -37,6 +38,8 @@ def create_instance(
"targetRef": target.reference,
},
}
if section_name:
model["spec"]["targetRef"]["sectionName"] = section_name

return cls(model, context=cluster.context)

Expand Down
3 changes: 3 additions & 0 deletions testsuite/kuadrant/policy/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def create_instance(
name: str,
parent: Referencable,
provider_secret_name: str,
section_name: str = None,
load_balancing: LoadBalancing = None,
labels: dict[str, str] = None,
):
Expand All @@ -86,6 +87,8 @@ def create_instance(

if load_balancing:
model["spec"]["loadBalancing"] = asdict(load_balancing)
if section_name:
model["spec"]["targetRef"]["sectionName"] = section_name

return cls(model, context=cluster.context)

Expand Down
13 changes: 11 additions & 2 deletions testsuite/kuadrant/policy/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,25 @@ def __init__(self, *args, **kwargs):
self.spec_section = None

@classmethod
def create_instance(cls, cluster: KubernetesClient, name, target: Referencable, labels: dict[str, str] = None):
def create_instance(
cls,
cluster: KubernetesClient,
name,
target: Referencable,
section_name: str = None,
labels: dict[str, str] = None,
):
"""Creates new instance of RateLimitPolicy"""
model = {
model: dict = {
"apiVersion": "kuadrant.io/v1",
"kind": "RateLimitPolicy",
"metadata": {"name": name, "labels": labels},
"spec": {
"targetRef": target.reference,
},
}
if section_name:
model["spec"]["targetRef"]["sectionName"] = section_name

return cls(model, context=cluster.context)

Expand Down
5 changes: 4 additions & 1 deletion testsuite/kuadrant/policy/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def create_instance(
name: str,
parent: Referencable,
issuer: Referencable,
section_name: str = None,
labels: dict[str, str] = None,
commonName: str = None,
duration: str = None,
Expand All @@ -24,7 +25,7 @@ def create_instance(
): # pylint: disable=invalid-name
"""Creates new instance of TLSPolicy"""

model = {
model: dict = {
"apiVersion": "kuadrant.io/v1",
"kind": "TLSPolicy",
"metadata": {"name": name, "labels": labels},
Expand All @@ -40,6 +41,8 @@ def create_instance(
},
},
}
if section_name:
model["spec"]["targetRef"]["sectionName"] = section_name

return cls(model, context=cluster.context)

Expand Down

0 comments on commit 489cc18

Please sign in to comment.