From dcd7b348d4683cccb784678b66f8fa1a46848ed2 Mon Sep 17 00:00:00 2001 From: fumingwei Date: Fri, 1 Nov 2024 17:10:47 +0800 Subject: [PATCH] fix:TSG-23289:Fix device tags render error. --- containers/base/templates/macros.j2 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/containers/base/templates/macros.j2 b/containers/base/templates/macros.j2 index f1249c27..a9d8ce5c 100644 --- a/containers/base/templates/macros.j2 +++ b/containers/base/templates/macros.j2 @@ -26,7 +26,7 @@ {%- set address = item.address ~ ":" ~ item.port -%} {%- do addresses.append(address) -%} {%- endfor -%} - {{ addresses | join(separator) }} + {{- addresses | join(separator) }} {%- endif %} {%- endmacro %} @@ -52,15 +52,15 @@ {% macro device_tag_list(device) -%} {%- set tags_list = [] -%} - {%- if device.tag is defined and device.tag %} - {%- for tag in device.tag %} + {%- if device.tags is defined and device.tags %} + {%- for tag in device.tags %} {%- for key, val in tag.items() %} {%- set tag_json = '{"tag":"' ~ key ~ '","value":"' ~ val ~ '"}' -%} {%- do tags_list.append(tag_json) -%} {%- endfor %} {%- endfor %} + {{- tags_list | join(',') }} {%- endif %} - {{ tags_list | join(',') }} {%- endmacro %} {% macro safe_read(data, path) -%} @@ -81,8 +81,8 @@ {% macro read_device_tag_value(device, key) -%} {%- set ns = namespace(value='') %} - {%- if device.tag is defined and device.tag %} - {%- for tag in device.tag %} + {%- if device.tags is defined and device.tags %} + {%- for tag in device.tags %} {%- if tag is mapping and key in tag %} {%- set ns.value = tag[key] %} {%- break %}