Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hcl instead of diff after triple backtick #2438

Open
1 task done
nitrocode opened this issue Aug 10, 2022 · 6 comments
Open
1 task done

Use hcl instead of diff after triple backtick #2438

nitrocode opened this issue Aug 10, 2022 · 6 comments
Labels
feature New functionality/enhancement Stale

Comments

@nitrocode
Copy link
Member

nitrocode commented Aug 10, 2022

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

if command != "" {
sepStart = fmt.Sprintf("Continued %s output from previous comment.\n<details><summary>Show Output</summary>\n\n", command) +
"```diff\n"
} else {
sepStart = "Continued from previous comment.\n<details><summary>Show Output</summary>\n\n" +
"```diff\n"
}

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

@nitrocode nitrocode added the feature New functionality/enhancement label Aug 10, 2022
@pauloconnor
Copy link
Contributor

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 #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"
    }

@nitrocode
Copy link
Member Author

@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.

@pauloconnor
Copy link
Contributor

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

@nitrocode
Copy link
Member Author

This is a duplicate of #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.

@rpdelaney
Copy link

rpdelaney commented Mar 9, 2023

#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.

@jeska
Copy link

jeska commented Jun 12, 2024

👋🏻 This is a feature our team would like to see too. We prefer the output with terraform or hcl formatting rather than diff, and the hard coding of diff means we cannot update the formatting of continued comments. I understand this might be difficult to code around since folks may have various different kinds of templates, but adding a +1 here for supporting a feature similar to this.

@dosubot dosubot bot added the Stale label Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement Stale
Projects
None yet
Development

No branches or pull requests

4 participants