-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Terragrunt integration and general parser (#24) * - add kw parser - add tg command methods * - add plan_all parse output progress - replace terra* command func cli params with **kw * add tgbinary to ci * - add tg shared doc string decorator - separate some of the public methods tg_xxx() | tf_xxx() - fix parse_args() styling * - Rollback parse_args() - Add tg global args to parse_args() - Add tg global args decorator - Add all param to tg_xxx methods * - mv tg flags before tf flags for cli args - add common tg args to tg methods * - fix tg source module warning - add output() fixture to tg test * bump version * Terragrunt support (#29) * Don't fail when resource_changes key not present in output (#27) * Resolves #26 tftest failed when terraform plan is empty * add missing copyright boilerplate Co-authored-by: Ludovico Magnocavallo <[email protected]> * Update CHANGELOG.md * Update CHANGELOG.md * v1.5.6 for pypi * made minimal changes to fix tests (now all passed locally for me) * added a bit of code to parse run-all output and test to assert output * added terragrunt run in single dir test case + simplified run-all * added test cases for terragrunt parse args * refactored terragrunt cmd line parameters parsing * refactored as a separated class(TerragruntTest) but reused most of TerraformTest Co-authored-by: Mike Brown II <[email protected]> Co-authored-by: Ludovico Magnocavallo <[email protected]> Co-authored-by: Ludovico Magnocavallo <[email protected]> * speed up tests(session scope to reuse fixtures) + work around for strange tf run-all plan behaviour * added back change log * adding newline at end of file * Adding terragrunt section to readme * added some doc strings * remove binary param from _clean_up to fix tests * Update README.md * Update README.md * Update CHANGELOG.md * Update tftest.py Co-authored-by: Marshall Mamiya <[email protected]> Co-authored-by: Ludovico Magnocavallo <[email protected]> Co-authored-by: Mike Brown II <[email protected]> Co-authored-by: Ludovico Magnocavallo <[email protected]>
- Loading branch information
1 parent
8106e54
commit 09e532b
Showing
13 changed files
with
354 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
terraform { | ||
source = "../..//apply" | ||
} | ||
|
||
inputs = { | ||
names = ["bar"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
include { | ||
path = find_in_parent_folders() | ||
} | ||
|
||
terraform { | ||
source = "../..//apply" | ||
} | ||
|
||
inputs = { | ||
names = ["foo"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
terraform { | ||
source = "..//apply" | ||
} | ||
|
||
generate "provider" { | ||
path = "provider.tf" | ||
if_exists = "overwrite_terragrunt" | ||
contents = <<EOF | ||
provider "null" {} | ||
EOF | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright 2019 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import pytest | ||
import tftest | ||
|
||
import os | ||
|
||
|
||
@pytest.fixture | ||
def run_all_apply_out(fixtures_dir): | ||
tg = tftest.TerragruntTest('tg_apply_all', fixtures_dir, tg_run_all=True) | ||
tg.setup() | ||
tg.apply(output=False, tg_non_interactive=True) | ||
yield tg.output() | ||
tg.destroy(auto_approve=True, tg_non_interactive=True) | ||
|
||
|
||
@pytest.fixture | ||
def run_all_plan_output(fixtures_dir): | ||
tg = tftest.TerragruntTest('tg_apply_all', fixtures_dir, tg_run_all=True) | ||
tg.setup() | ||
return tg.plan(output=True, tg_working_dir=os.path.join(fixtures_dir, 'tg_apply_all')) | ||
|
||
|
||
@pytest.fixture | ||
def plan_foo_output(fixtures_dir): | ||
tg = tftest.TerragruntTest(os.path.join('tg_apply_all', 'foo'), fixtures_dir) | ||
tg.setup() | ||
return tg.plan(output=True) | ||
|
||
|
||
@pytest.fixture | ||
def bar_output(fixtures_dir): | ||
tg = tftest.TerragruntTest(os.path.join('tg_apply_all', 'bar'), fixtures_dir) | ||
tg.setup() | ||
tg.apply(output=False, tg_non_interactive=True) | ||
yield tg.output() | ||
tg.destroy(auto_approve=True, tg_non_interactive=True) | ||
|
||
|
||
def test_run_all_apply(run_all_apply_out): | ||
triggers = [o["triggers"] for o in run_all_apply_out] | ||
assert [{'name': 'foo', 'template': 'sample template foo'}] in triggers | ||
assert [{'name': 'bar', 'template': 'sample template bar'}] in triggers | ||
assert [{'name': 'one', 'template': 'sample template one'}, | ||
{'name': 'two', 'template': 'sample template two'}] in triggers | ||
assert len(run_all_apply_out) == 3 | ||
|
||
|
||
def test_tg_single_directory_apply(bar_output): | ||
assert bar_output["triggers"] == [{'name': 'bar', 'template': 'sample template bar'}] | ||
|
||
|
||
def test_run_all_plan(run_all_plan_output): | ||
triggers = [o.outputs["triggers"] for o in run_all_plan_output] | ||
assert [{'name': 'foo', 'template': 'sample template foo'}] in triggers | ||
assert [{'name': 'bar', 'template': 'sample template bar'}] in triggers | ||
assert [{'name': 'one', 'template': 'sample template one'}, | ||
{'name': 'two', 'template': 'sample template two'}] in triggers | ||
assert len(run_all_plan_output) == 3 | ||
|
||
|
||
def test_tg_single_directory_plan(plan_foo_output): | ||
assert plan_foo_output.outputs['triggers'] == [{'name': 'foo', 'template': 'sample template foo'}] | ||
assert plan_foo_output.variables['names'] == ['foo'] |
Oops, something went wrong.