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

Lines that starts with a hyphen are interpretated as "Removed" #8

Open
Fresa opened this issue Apr 8, 2021 · 4 comments
Open

Lines that starts with a hyphen are interpretated as "Removed" #8

Fresa opened this issue Apr 8, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Fresa
Copy link

Fresa commented Apr 8, 2021

At least that's what I think is causing the following issue.
Left is the output from Terraform Plan.
Right is the comment generated in the PR by the terraform-pr-commenter action.

image

Each line that starts with either the Terraform Remove hyphen sign or a yaml hyphen indicating a list item are highlighted in the comment as being removed.

I have blanked some values that contained "sensitive" information.

Download action repository 'robburger/terraform-pr-commenter@v1'
v1 is currently v1.3.0
0.14.9: Pulling from hashicorp/terraform

@robburger robburger added the bug Something isn't working label Apr 24, 2021
@robburger
Copy link
Owner

Thanks @Fresa - I'll try to think of a creative way to resolve this

@MPV
Copy link

MPV commented Oct 21, 2021

In my experience, formatting the code block as terraform seems to give quite good highlighting for diffs nowadays, i.e:

# kubectl_manifest.argocd_bootstrap will be updated in-place
~ resource "kubectl_manifest" "argocd_bootstrap" {
  source:
    helm:
      parameters:
      - name: argocd.namespace
        value: argocd
-     - name: ingress_nginx.namespace
-       value: ingress-nginx
      valueFiles:
      - values.yaml
+     - values.prod.yaml
}

diff isn't too bad either:

# kubectl_manifest.argocd_bootstrap will be updated in-place
~ resource "kubectl_manifest" "argocd_bootstrap" {
  source:
    helm:
      parameters:
      - name: argocd.namespace
        value: argocd
-     - name: ingress_nginx.namespace
-       value: ingress-nginx
      valueFiles:
      - values.yaml
+     - values.prod.yaml
}

But hey, the kind of beautifully highlighted colors for "changes in resources" you're doing here is also really helpful. 🎉

colored output

Would be cool to solve it for all of GitHub though, and looking at https://github.com/github/linguist/blob/master/vendor/README.md it seems like this is the implementation that powers it: https://github.com/alexlouden/Terraform.tmLanguage/blob/master/Terraform.tmLanguage

I haven't figured out the details of how to do it in that file format, but I also raised an issue over there for discussing it: SublimeText/Terraform#51

@jcogilvie
Copy link

jcogilvie commented Nov 15, 2021

Also experiencing this issue. One of the context clues here is we can pick up <<-EOT as an indicator that what follows isn't strictly terraform output, so maybe treat lines a little differently until we hit EOT?

@jcogilvie
Copy link

jcogilvie commented Feb 25, 2022

If the terraform output is colorized, then the hyphens for "removals" are red and the ones for yaml lists are not. Maybe the commenter could use that fact instead of beginning by stripping the color?

Edit: yep, fixed in my fork. PR is up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants