Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/generic_config_updater/test_kubernetes_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@
]


def add_namespace_indentation(multiline_string, spaces=4):
return multiline_string.replace('\n', '\n' + ' ' * spaces)


@pytest.fixture(autouse=True)
def setup_env(duthosts, rand_one_dut_hostname):
"""
Expand Down Expand Up @@ -268,6 +272,13 @@ def k8s_config_update(duthost, test_data):
logger.info("tmpfile {}".format(tmpfile))
json_patch = format_json_patch_for_multiasic(duthost=duthost, json_data=json_patch)

if duthost.is_multi_asic:
json_namespace = '/localhost'
for patch in json_patch:
if 'path' in patch:
patch['path'] = re.sub(r'^/', f'/{json_namespace}/', patch['path'])
target_config = [add_namespace_indentation(item) for item in target_config]

try:
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)

Expand Down