Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GoogleCloudPlatform/terraform-python-testing-helper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.5
Choose a base ref
...
head repository: GoogleCloudPlatform/terraform-python-testing-helper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jun 21, 2024

  1. Clean up terraform runtime files (#82)

    * clean up terraform runtime files
    
    * replace deprecated template_file datasource from template provider with templatefile built-in function
    elstak authored Jun 21, 2024
    Copy the full SHA
    897f228 View commit details
Showing with 8 additions and 9 deletions.
  1. +1 −9 test/fixtures/apply/main.tf
  2. +1 −0 test/fixtures/apply/template.tftpl
  3. +6 −0 tftest.py
10 changes: 1 addition & 9 deletions test/fixtures/apply/main.tf
Original file line number Diff line number Diff line change
@@ -14,18 +14,10 @@
* limitations under the License.
*/

data "template_file" "sample" {
for_each = toset(var.names)
template = "sample template $${name}"
vars = {
name = each.key
}
}

resource "null_resource" "sample" {
for_each = toset(var.names)
triggers = {
name = each.key
template = data.template_file.sample[each.key].rendered
template = templatefile("${path.module}/template.tftpl", { name = each.key })
}
}
1 change: 1 addition & 0 deletions test/fixtures/apply/template.tftpl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sample template ${name}
6 changes: 6 additions & 0 deletions tftest.py
Original file line number Diff line number Diff line change
@@ -365,9 +365,15 @@ def remove_readonly(func, path, excinfo):
path = os.path.join(tfdir, '.terraform')
if os.path.isdir(path):
shutil.rmtree(path, onerror=remove_readonly)
path = os.path.join(tfdir, '.terraform.lock.hcl')
if os.path.isfile(path):
os.unlink(path)
path = os.path.join(tfdir, 'terraform.tfstate')
if os.path.isfile(path):
os.unlink(path)
for path in glob.glob(os.path.join(tfdir, 'terraform.tfstate.backup*')):
if os.path.isfile(path):
os.unlink(path)
path = os.path.join(tfdir, '**', '.terragrunt-cache*')
for tg_dir in glob.glob(path, recursive=True):
if os.path.isdir(tg_dir):