Skip to content

Commit 7d6d4d7

Browse files
committed
feat: determine namespace from testcase name and provide it as variable
1 parent 1ebc9e7 commit 7d6d4d7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/beku/kuttl.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import re
77
from dataclasses import dataclass, field
88
from functools import cached_property
9+
from hashlib import sha256
910
from itertools import product, chain
1011
from os import walk, path, makedirs
1112
from shutil import copy2
@@ -128,6 +129,7 @@ def expand(self, template_dir: str, target_dir: str) -> None:
128129
trim_blocks=True
129130
)
130131
test_env.globals['lookup'] = ansible_lookup
132+
test_env.globals['NAMESPACE'] = determine_namespace(self.tid)
131133
sub_level: int = 0
132134
for root, dirs, files in walk(td_root):
133135
sub_level += 1
@@ -320,6 +322,9 @@ def expand(suite: str, effective_test_suites: List[EffectiveTestSuite], template
320322
f"Cannot expand test suite [{suite}] because cannot find it in [{kuttl_tests}]") from exc
321323
return 0
322324

325+
def determine_namespace(testcase_name: str) -> str:
326+
hash = sha256(testcase_name.encode('utf-8')).hexdigest()
327+
return f"kuttl-{testcase_name[:32]}-{hash[:10]}"
323328

324329
def _expand_kuttl_tests(test_cases, output_dir: str, kuttl_tests: str) -> None:
325330
"""Generate the kuttl-tests.yaml file and fill in paths to tests."""

src/beku/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package version."""
2-
__version__ = "0.0.9"
2+
__version__ = "0.0.10"

0 commit comments

Comments
 (0)