From 59d1c2b041b7b91e6a66fb88eaeb3bad250abf77 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Fri, 14 Feb 2020 11:49:38 -0800 Subject: [PATCH 1/2] Allow passing filename as argument to landscape This allows you to pass in a file not via stdin. --- lib/terraform_landscape/cli.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/terraform_landscape/cli.rb b/lib/terraform_landscape/cli.rb index 2f618d7..bed3496 100644 --- a/lib/terraform_landscape/cli.rb +++ b/lib/terraform_landscape/cli.rb @@ -50,7 +50,7 @@ def define_commands def print(options) printer = Printer.new(@output) - printer.process_stream(STDIN, options) + printer.process_stream(ARGF, options) end end end From efa5cbbe76378600c8ed1a481357cca96d57e1a1 Mon Sep 17 00:00:00 2001 From: Shane da Silva Date: Fri, 14 Feb 2020 11:49:56 -0800 Subject: [PATCH 2/2] Convert Windows newlines to Unix newlines When we preprocess the input, our regex patterns only work with Unix newlines. --- lib/terraform_landscape/printer.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/terraform_landscape/printer.rb b/lib/terraform_landscape/printer.rb index 54762fe..c301daa 100644 --- a/lib/terraform_landscape/printer.rb +++ b/lib/terraform_landscape/printer.rb @@ -57,6 +57,9 @@ def process_stream(io, options = {}) # rubocop:disable Metrics/MethodLength def process_string(plan_output) # rubocop:disable Metrics/MethodLength scrubbed_output = strip_ansi(plan_output) + # Our grammar assumes output with Unix line endings + scrubbed_output.gsub!("\r\n", "\n") + # Remove initialization messages like # "- Downloading plugin for provider "aws" (1.1.0)..." # "- module.base_network"