coinbase / terraform-landscape

Improve Terraform's plan output to be easier to read and understand
Apache License 2.0
1.59k stars 116 forks source link

Support UTF-8 Charset #90

Closed DWSR closed 5 years ago

DWSR commented 5 years ago

What I Did

Run terraform plan

What I Expected

Plan output

What Happened

source:           error: non-ASCII character detected. Use --trace to view backtrace

Traceback:

    source:           Traceback (most recent call last):
        21: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/bin/landscape:23:in `<main>'
        20: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/bin/landscape:23:in `load'
        19: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/bin/landscape:7:in `<top (required)>'
        18: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:25:in `run'
        17: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/delegates.rb:15:in `run!'
        16: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/runner.rb:68:in `run!'
        15: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/runner.rb:446:in `run_active_command'
        14: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/command.rb:153:in `run'
        13: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/command.rb:182:in `call'
        12: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:34:in `block (2 levels) in
define_commands'
        11: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:53:in `print'
        10: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/printer.rb:42:in `process_stream'
         9: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/printer.rb:97:in `process_string'
         8: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:59:in `display'
         7: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:59:in `each'
         6: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:60:in `block in
display'
         5: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:86:in `display_resource'
         4: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:86:in `each'
         3: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:89:in `block in
display_resource'
         2: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:162:in `display_attribute'
         1: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:221:in `display_added_or_removed_attribute'
/usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:221:in `undump': non-ASCII character detected (RuntimeError)
sds commented 5 years ago

Hey @DWSR, can you provide a reproducible example where we can run cat example.txt | landscape to reproduce the problem you're seeing? Thanks!

hihihiroro commented 5 years ago

Hi, @sds

I found same error.

cat example.txt
  + module.test.aws_iam_policy.s3-user-policy
      id:                                                      <computed>
      arn:                                                     <computed>
      description:                                             "s3:exampleへ通信"
      name:                                                    "sys-dev"
      path:                                                    "/"
bash-3.2$ ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]
bash-3.2$ landscape --version
Terraform Landscape 0.3.1
bash-3.2$ cat example.txt |landscape --trace
+ module.test.aws_iam_policy.s3-user-policy
    id:            "<computed>"
    arn:           "<computed>"
    description:   Traceback (most recent call last):
    21: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/bin/landscape:23:in `<main>'
    20: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/bin/landscape:23:in `load'
    19: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/bin/landscape:7:in `<top (required)>'
    18: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:25:in `run'
    17: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/delegates.rb:15:in `run!'
    16: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/runner.rb:68:in `run!'
    15: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/runner.rb:446:in `run_active_command'
    14: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/command.rb:153:in `run'
    13: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/commander-4.4.7/lib/commander/command.rb:182:in `call'
    12: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:34:in `block (2 levels) in define_commands'
    11: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/cli.rb:53:in `print'
    10: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/printer.rb:42:in `process_stream'
     9: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/printer.rb:97:in `process_string'
     8: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:59:in `display'
     7: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:59:in `each'
     6: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:60:in `block in display'
     5: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:86:in `display_resource'
     4: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:86:in `each'
     3: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:89:in `block in display_resource'
     2: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:162:in `display_attribute'
     1: from /usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:221:in `display_added_or_removed_attribute'
/usr/local/Cellar/terraform_landscape/0.3.1/libexec/gems/terraform_landscape-0.3.1/lib/terraform_landscape/terraform_plan.rb:221:in `undump': non-ASCII character detected (RuntimeError)
dozen commented 5 years ago

I added fail test case.

https://circleci.com/gh/dozen/terraform-landscape/10?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link

fix: #91

sds commented 5 years ago

Fixed in #91. Thanks @dozen!