dineshba / tf-summarize

A command-line utility to print the summary of the terraform plan
MIT License
528 stars 38 forks source link

Markdown table format is not compatible with github/gitlab #25

Closed stv-io closed 1 year ago

stv-io commented 1 year ago

Hey all, fantastic tool, requesting a small change / improvement, to be able to integrate this in CI pipelines, and summarize the output nicely.

Currently, it seems that the markdown table is using an old markdown syntax.

❯ tf-summarize -out=summary.md tfplan 
Written plan summary to summary.md

renders the below, escaping in backticks

Current

+--------+------------------------------------------+
| CHANGE |                   NAME                   |
+--------+------------------------------------------+
| update | module.ec2_instance.aws_instance.this[0] |
+--------+------------------------------------------+

In rendered markdown in github, this yields

+--------+------------------------------------------+ | CHANGE | NAME | +--------+------------------------------------------+ | update | module.ec2_instance.aws_instance.this[0] | +--------+------------------------------------------+

In a gitlab comment this would be

image

This is clearly not as it should be however if it's changed to:

Expected

| CHANGE |                   NAME                   |
|--------|------------------------------------------|
| update | module.ec2_instance.aws_instance.this[0] |

it renders as expected

CHANGE NAME
update module.ec2_instance.aws_instance.this[0]

and

image

References

dineshba commented 1 year ago

Hi @stv-io, Thanks for trying out the tool.

For markdown output, you have to add -md flag

❯ tf-summarize -md -out=summary.md tfplan 

Please try it and let us know if you have any issue with the output

stv-io commented 1 year ago

sorry, seems like I should have RTFM'd, indeed it works, thank you 🙇🏼

❯ tf-summarize -md -out=summary.md tfplan
Written plan summary to summary.md

tf-project-example/shared
❯ cat summary.md
| CHANGE |                    NAME                    |
|--------|--------------------------------------------|
| update | `module.ec2_instance.aws_instance.this[0]` |
CHANGE NAME
update module.ec2_instance.aws_instance.this[0]