dineshba/tf-summarize

tf-summarize produces malformed markdown table when both `-md` and `-out` are used

Closed this issue ยท 1 comments

mdb commented

๐Ÿ‘‹ Hi @dineshba - Thanks for your work on tf-summarize.

When tf-summarize is used with a -md flag, it correctly prints multiple tables, thanks to this code:

https://github.com/dineshba/tf-summarize/blob/main/writer/table.go#L65-L66

However, when both -md and -out are used, the newline separating the tables is evidently absent, which results in a single malformed markdown table.

Actual behavior

When tf-summarize is invoked with both -md and -out, the newline separating the rendered markdown tables is evidently stripped, which results in a single malformed markdown table like the following:

| CHANGE |                       RESOURCE                        |
|--------|-------------------------------------------------------|
| add    | `incident_catalog_entries.services`                   |
|        | `incident_catalog_type.service`                       |
|        | `incident_catalog_type_attribute.service_description` |
|        | `incident_catalog_type_attribute.service_owner`       |
|        | `incident_catalog_type_attribute.service_tags`        |
| CHANGE |           OUTPUT           |
|--------|----------------------------|
| add    | `incident_catalog_entries` |

When rendered by the GitHub web UI, that โ˜๏ธ markdown table appears as as a single, malformed table:

CHANGE RESOURCE
add incident_catalog_entries.services
incident_catalog_type.service
incident_catalog_type_attribute.service_description
incident_catalog_type_attribute.service_owner
incident_catalog_type_attribute.service_tags
CHANGE OUTPUT
-------- ----------------------------
add incident_catalog_entries

Expected behavior

By contrast, I'd expect the use of both -md and -out would write two markdown tables, like the following:

| CHANGE |                       RESOURCE                        |
|--------|-------------------------------------------------------|
| add    | `incident_catalog_entries.services`                   |
|        | `incident_catalog_type.service`                       |
|        | `incident_catalog_type_attribute.service_description` |
|        | `incident_catalog_type_attribute.service_owner`       |
|        | `incident_catalog_type_attribute.service_tags`        |

| CHANGE |           OUTPUT           |
|--------|----------------------------|
| add    | `incident_catalog_entries` |

When rendered by GitHub, โ˜๏ธ this markdown table appears two tables, as desired:

CHANGE RESOURCE
add incident_catalog_entries.services
incident_catalog_type.service
incident_catalog_type_attribute.service_description
incident_catalog_type_attribute.service_owner
incident_catalog_type_attribute.service_tags
CHANGE OUTPUT
add incident_catalog_entries