Skip to content

Commit

Permalink
fix: do not change module-metadata.json if hook fails (#781)
Browse files Browse the repository at this point in the history
* fix: do not change module-metadata.json if hook fails

* fix: do not change module-metadata.json if hook fails

---------

Co-authored-by: Andrej <akocbek@ie.ibm.com>
  • Loading branch information
akocbek and akocbekIBM authored Oct 13, 2023
1 parent 6ac7d20 commit 0ec42f0
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions module-assets/ci/terraformConfigInspect.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python

import glob
import os
import shutil
import sys
from pathlib import Path
Expand All @@ -23,13 +22,23 @@ def get_terraform_provider():


def run_metadata_generator(file_path, terraform_provider):
tf_config_inspect_command = ""
if terraform_provider:
os.system(
"terraform-config-inspect --json --metadata %s > %s"
% (terraform_provider, file_path)
tf_config_inspect_command = "terraform-config-inspect --json --metadata %s" % (
terraform_provider
)
else:
os.system("terraform-config-inspect --json > %s" % (file_path))
tf_config_inspect_command = "terraform-config-inspect --json"

proc = Popen(tf_config_inspect_command, stdout=PIPE, stderr=PIPE, shell=True)
output, error = proc.communicate()

if proc.returncode != 0:
print(error)
sys.exit(proc.returncode)
else:
with open(file_path, "wb") as binary_file:
binary_file.write(output)


def remove_tf_IBM_provider():
Expand Down

0 comments on commit 0ec42f0

Please sign in to comment.