atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Threaded comments in Azure Devops

Open pszypowicz opened this issue 2 years ago • 2 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

See big Atlantis Plan/Apply output in Threaded mode instead of separate comments in the main thread.

Describe the solution you'd like

Currently when Atlantis comments in the PR, its is updated as "parent" comment, in the main thread. You have to read it Bottom-Up. It would be much better to just continue in "reply".

How it looks currently: Zrzut ekranu 2022-09-2 o 12 08 11 Zrzut ekranu 2022-09-2 o 12 08 01

How it could look:

threaded

pszypowicz avatar Sep 02 '22 10:09 pszypowicz

Also it would be great if Atlantis could be more inteligent when splitting output and split between resources, not in the middle of a one.

pszypowicz avatar Sep 02 '22 10:09 pszypowicz

PRs are welcome.

jamengual avatar Sep 02 '22 19:09 jamengual

I think in general it would be great if we could somehow split the output.

I am currently doing for example this, by injecting into MD tags: image

The security scanning has its own section, as well in the background the plan JSON gets parsed to extract delete/create/update actions and it adds them dynamically, like: image

It would be good to be able to manipulate the output / create custom sections somehow.

Dilergore avatar Oct 10 '22 15:10 Dilergore

@Dilergore that looks very cool. Could you show us how you inject the markdown?

nitrocode avatar Nov 23 '22 05:11 nitrocode

@Dilergore that looks very cool. Could you show us how you inject the markdown?

I am using python as custom scripts, but this would basically work with any scripting language which can output stuff. I am injecting Markdown tags into the output at places where I need them to break the output. For example:

Once Terraform runs successfully I inject

print("```")
print("</details>")

The above closes the "> Output" section.

After that before I run the Wiz scanning I have:

print("### Summary")
print("<details>")
print("<summary>Wiz Scan</summary>")
print("")
print('```diff')

The next section (which creates the summary for resource creations/deletes/updates) starts like:

print("```")
print("</details>")
print("<details>")
print("<summary>Resource " + actionText1 + "</summary>")
print("")
print('```diff')
print("The following resources will be " + actionText2 + ":")

And at the end I inject - which is mainly required to be able to properly close the entire thing, as Atlantis also injects md close tags at the end like it would normally do to close the original "> Output" section:

print("```")
print("</details>")
print("<details>")
print("<summary>Commands</summary>")
print("")
print("```")

Dilergore avatar Nov 23 '22 07:11 Dilergore

Ah that makes sense. Interesting. So you write a python script with print statements to inject html into the output and save a python script on to the container? Then run the script on a run step prior to the plan? Clever!

nitrocode avatar Nov 24 '22 02:11 nitrocode

Ah that makes sense. Interesting. So you write a python script with print statements to inject html into the output and save a python script on to the container? Then run the script on a run step prior to the plan? Clever!

A bit more complex than that what I have but in a nutshell, yes. I have Python scripts because I have a very custom and complex custom workflow, with credential injections and a bunch of other customizations mainly to deploy to Azure used by 40+ teams.

This is just another thing which I developed so people can better see what is happening. They have very long outputs sometimes for big TF states, and it can be very hard to go through it. So this customization helps with that by dividing the output to different sections using MD and HTML (MD close and open tags for the code blocks and HTML for the drop-downs). I store the scripts on an Azure Storage Account, which makes it very easy to change the scripts and also to be able to quickly test in the test environment and to be able to deploy the customizations most of the time without downtime (unless you have a workflow change). The storage account is mounted under an Azure WebApp which runs the container. Most of the steps I have are Python coded, I am only using the init from the built-in steps.

If you have a simpler environment, what you could do is to use the built-in init and plan steps and yes, use a run after to divide and do whatever you want, like here, parse the JSON converted plan file and extract creations/deletions/updates.

Dilergore avatar Nov 24 '22 07:11 Dilergore