Skip to content

Commit c7535da

Browse files
committed
feat: determine namespace from testcase name and provide it as variable
1 parent 37cfcab commit c7535da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/beku/kuttl.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import re
88
from dataclasses import dataclass, field
99
from functools import cached_property
10+
from hashlib import sha256
1011
from itertools import product, chain
1112
from os import walk, path, makedirs
1213
from shutil import copy2
@@ -132,6 +133,7 @@ def expand(self, template_dir: str, target_dir: str) -> None:
132133
_mkdir_ignore_exists(tc_root)
133134
test_env = Environment(loader=FileSystemLoader(path.join(template_dir, self.name)), trim_blocks=True)
134135
test_env.globals["lookup"] = ansible_lookup
136+
test_env.globals["NAMESPACE"] = determine_namespace(self.tid)
135137
sub_level: int = 0
136138
for root, dirs, files in walk(td_root):
137139
sub_level += 1
@@ -328,6 +330,11 @@ def expand(
328330
return 0
329331

330332

333+
def determine_namespace(testcase_name: str) -> str:
334+
hash = sha256(testcase_name.encode("utf-8")).hexdigest()
335+
return f"kuttl-{testcase_name[:32]}-{hash[:10]}"
336+
337+
331338
def _expand_kuttl_tests(test_cases, output_dir: str, kuttl_tests: str) -> None:
332339
"""Generate the kuttl-tests.yaml file and fill in paths to tests."""
333340
env = Environment(loader=FileSystemLoader(path.dirname(kuttl_tests)))

src/beku/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Package version."""
22

3-
__version__ = "0.0.9"
3+
__version__ = "0.0.10"

0 commit comments

Comments
 (0)