Skip to content

Commit efae9ac

Browse files
authored
Merge pull request #63 from dflook/fix-lock-plan-diff
Don't include state lock status in plan
2 parents 46179c7 + a51f395 commit efae9ac

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

image/tools/compact_plan.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ def compact_plan(input):
1818
plan = True
1919

2020
if plan:
21-
yield line
21+
if not (line.startswith('Releasing state lock. This may take a few moments...')
22+
or line.startswith('Acquiring state lock. This may take a few moments...')):
23+
yield line
2224
else:
2325
buffer.append(line)
2426

tests/test_compact_plan.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,64 @@ def test_plan_14():
169169
output = '\n'.join(compact_plan(input.splitlines()))
170170
assert output == expected_output
171171

172+
def test_plan_15():
173+
input = """
174+
175+
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
176+
+ create
177+
178+
Terraform will perform the following actions:
179+
180+
# random_string.my_string will be created
181+
+ resource "random_string" "my_string" {
182+
+ id = (known after apply)
183+
+ length = 11
184+
+ lower = true
185+
+ min_lower = 0
186+
+ min_numeric = 0
187+
+ min_special = 0
188+
+ min_upper = 0
189+
+ number = true
190+
+ result = (known after apply)
191+
+ special = true
192+
+ upper = true
193+
}
194+
195+
Plan: 1 to add, 0 to change, 0 to destroy.
196+
197+
Changes to Outputs:
198+
+ s = "string"
199+
"""
200+
201+
expected_output = """Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
202+
+ create
203+
204+
Terraform will perform the following actions:
205+
206+
# random_string.my_string will be created
207+
+ resource "random_string" "my_string" {
208+
+ id = (known after apply)
209+
+ length = 11
210+
+ lower = true
211+
+ min_lower = 0
212+
+ min_numeric = 0
213+
+ min_special = 0
214+
+ min_upper = 0
215+
+ number = true
216+
+ result = (known after apply)
217+
+ special = true
218+
+ upper = true
219+
}
220+
221+
Plan: 1 to add, 0 to change, 0 to destroy.
222+
223+
Changes to Outputs:
224+
+ s = "string\""""
225+
226+
output = '\n'.join(compact_plan(input.splitlines()))
227+
assert output == expected_output
228+
229+
172230
def test_error_11():
173231
input = """
174232
Error: random_string.my_string: length: cannot parse '' as int: strconv.ParseInt: parsing "ten": invalid syntax
@@ -256,3 +314,69 @@ def test_no_output():
256314
output = '\n'.join(compact_plan(input.splitlines()))
257315
assert output == expected_output
258316

317+
def test_state_lock_12():
318+
input = """Acquiring state lock. This may take a few moments...
319+
Refreshing Terraform state in-memory prior to plan...
320+
The refreshed state will be used to calculate this plan, but will not be
321+
persisted to local or remote state storage.
322+
323+
Acquiring state lock. This may take a few moments...
324+
Releasing state lock. This may take a few moments...
325+
326+
------------------------------------------------------------------------
327+
Acquiring state lock. This may take a few moments...
328+
329+
An execution plan has been generated and is shown below.
330+
Resource actions are indicated with the following symbols:
331+
+ create
332+
Acquiring state lock. This may take a few moments...
333+
334+
Terraform will perform the following actions:
335+
336+
# random_string.my_string will be created
337+
+ resource "random_string" "my_string" {
338+
+ id = (known after apply)
339+
+ length = 11
340+
+ lower = true
341+
Acquiring state lock. This may take a few moments...
342+
+ min_lower = 0
343+
+ min_numeric = 0
344+
+ min_special = 0
345+
+ min_upper = 0
346+
+ number = true
347+
+ result = (known after apply)
348+
+ special = true
349+
+ upper = true
350+
Releasing state lock. This may take a few moments...
351+
}
352+
353+
Plan: 1 to add, 0 to change, 0 to destroy.
354+
Releasing state lock. This may take a few moments...
355+
Releasing state lock. This may take a few moments...
356+
"""
357+
358+
expected_output = """An execution plan has been generated and is shown below.
359+
Resource actions are indicated with the following symbols:
360+
+ create
361+
362+
Terraform will perform the following actions:
363+
364+
# random_string.my_string will be created
365+
+ resource "random_string" "my_string" {
366+
+ id = (known after apply)
367+
+ length = 11
368+
+ lower = true
369+
+ min_lower = 0
370+
+ min_numeric = 0
371+
+ min_special = 0
372+
+ min_upper = 0
373+
+ number = true
374+
+ result = (known after apply)
375+
+ special = true
376+
+ upper = true
377+
}
378+
379+
Plan: 1 to add, 0 to change, 0 to destroy."""
380+
381+
output = '\n'.join(compact_plan(input.splitlines()))
382+
assert output == expected_output

0 commit comments

Comments
 (0)