atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

Use `hcl` instead of `diff` after triple backtick

Open nitrocode opened this issue 2 years ago • 6 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

I'd like to see the same colored output in atlantis' comment as I would locally in my command line

Describe the solution you'd like

Let's use hcl instead of diff after the triple backtick

https://github.com/runatlantis/atlantis/blob/b409cb8470c137b6a321d0642b42fbb96f60df56/server/events/vcs/azuredevops_client.go#L102

https://github.com/runatlantis/atlantis/blob/b409cb8470c137b6a321d0642b42fbb96f60df56/server/events/vcs/github_client.go#L186-L192

Currently we see this using diff

before-diff

If we use hcl the github comment syntax highlighting would match what we see locally

after-hcl

Describe the drawbacks of your solution

I do not know if azure devops vcs supports the hcl coloring syntax. I know the github vcs does.

Describe alternatives you've considered

  • Implement the above and add a flag to override the the text following the triple backtick
  • or live with the current implementation

related

  • https://github.com/runatlantis/atlantis/issues/1899
  • https://github.com/runatlantis/atlantis/pull/2647

nitrocode avatar Aug 10 '22 18:08 nitrocode

I think the reason why diff is used over hcl is due to GitHub handling diff correctly when +. - etc are the first characters of the strings (I kinda broke this working properly https://github.com/runatlantis/atlantis/issues/2425)

This is what you'd see if it was working properly

HCL

  # module.redacted.aws_route53_record.redacted_record will be updated in-place
~ resource "aws_route53_record" "redacted_record" {
        fqdn    = "redacted.redacted.redacted.io"
        id      = "redacted_redacted.redacted.redacted.io_A"
        name    = "redacted.redacted.redacted.io"
      ~ records = [
            "foo",
          - "redacted",
        ] -> (known after apply)
        ttl     = 300
        type    = "A"
        zone_id = "redacted"
    }

Diff

  # module.redacted.aws_route53_record.redacted_record will be updated in-place
! resource "aws_route53_record" "redacted_record" {
        fqdn    = "redacted.redacted.redacted.io"
        id      = "redacted_redacted.redacted.redacted.io_A"
        name    = "redacted.redacted.redacted.io"
!       records = [
            "foo",
-           "redacted",
        ] -> (known after apply)
        ttl     = 300
        type    = "A"
        zone_id = "redacted"
    }

pauloconnor avatar Aug 16 '22 18:08 pauloconnor

@pauloconnor hmmm I'm not sure I follow. I would much prefer the hcl syntax than the diff syntax. Are you saying that the hcl syntax doesn't make the deletion as obvious as the diff syntax?

I suppose this is where the custom templating comes in in the next version.

To me, it doesn't make sense why we would use a different syntax than the native hcl. The diff syntax, imho, should be an option and hcl should be preferred.

nitrocode avatar Nov 19 '22 15:11 nitrocode

@nitrocode I think it boils down to diff making changes more obvious than hcl does. Personal preference as to which you prefer.

pauloconnor avatar Nov 20 '22 12:11 pauloconnor

This is a duplicate of https://github.com/runatlantis/atlantis/issues/1339 apparently.

Perhaps the best way to implement this then is with a feature flag such as --markdown-plan-color and it can default to diff and set to hcl for people that want to change it. It would also meaning restoring the plan output so its not modified for the diff type.

nitrocode avatar Dec 29 '22 02:12 nitrocode

#1339 was closed with a feature that allows the user to supply their own templates. I'm taking that as a signal that they don't want to do the work to support variants of the templates they already maintain. Edit: ...which is completely fair, to be clear.

rpdelaney avatar Mar 09 '23 17:03 rpdelaney