Skip to content

Commit

Permalink
Merge pull request #45 from coinbase/fix-dashed-lines
Browse files Browse the repository at this point in the history
Fix handling of dashed line separators after refresh output
  • Loading branch information
grahamjenson authored Nov 14, 2017
2 parents 076bc72 + 4bd82b3 commit 11dcd4f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Terraform Landscape Change Log

## 0.1.17

* Fix handling of dashed line separators after state refresh output

## 0.1.16

* Fix handling of initialization messages output by `terraform init`
Expand Down
3 changes: 3 additions & 0 deletions lib/terraform_landscape/printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def process_string(plan_output)
# as these break the parser which thinks "-" is a resource deletion
scrubbed_output.gsub!(/^- .*\.\.\.$/, '')

# Remove separation lines that appear after refreshing state
scrubbed_output.gsub!(/^-+$/, '')

# Remove preface
if (match = scrubbed_output.match(/^Path:[^\n]+/))
scrubbed_output = scrubbed_output[match.end(0)..-1]
Expand Down
2 changes: 1 addition & 1 deletion lib/terraform_landscape/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# Defines the gem version.
module TerraformLandscape
VERSION = '0.1.16'.freeze
VERSION = '0.1.17'.freeze
end
29 changes: 29 additions & 0 deletions spec/printer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,34 @@
No changes
OUT
end

context 'when output contains a separator after refreshing state' do
let(:terraform_output) { normalize_indent(<<-TXT) }
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_vpc.poc: Refreshing state... (ID: ##vpc-xxxxxxxxxxxxx)
data.aws_iam_policy_document.flowlogs: Refreshing state...
data.aws_iam_policy_document.rds_assume_policy: Refreshing state...
data.aws_iam_policy_document.flowlogs_assume_role_policy: Refreshing state...
aws_iam_role.rds: Refreshing state... (ID: xxxxxxxxxxxxxxxxxRole)
aws_iam_role.flowlogs: Refreshing state... (ID: xxxxxxxxxxxxxxRole)
aws_iam_role_policy.flowlogs: Refreshing state... (ID: xxxxxxxxxxxxxCreatePolicy)
aws_iam_role_policy_attachment.rds: Refreshing state... (ID: xxxxxxxxxxxxxxRole-20171030050803915500000001)
------------------------------------------------------------------------
No changes. Infrastructure is up-to-date.
This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.
TXT

it { should == normalize_indent(<<-OUT) }
No changes
OUT
end
end
end

0 comments on commit 11dcd4f

Please sign in to comment.