From af3d9d67659282788bcfa0968f5c9c1ac2fab81b Mon Sep 17 00:00:00 2001 From: jem Date: Tue, 22 Oct 2019 09:29:07 +0200 Subject: [PATCH] fixed output --- build.py | 3 ++- src/main/python/ddadevops/__init__.py | 2 +- src/main/python/ddadevops/terraform.py | 9 +++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/build.py b/build.py index 3689641..f278e3e 100644 --- a/build.py +++ b/build.py @@ -27,7 +27,7 @@ use_plugin("python.distutils") default_task = "publish" name = "ddadevops" -version = "0.3.0" +version = "0.3.3" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" description = __doc__ authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] @@ -52,6 +52,7 @@ def initialize(project): 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Topic :: Software Development :: Build Tools', ]) diff --git a/src/main/python/ddadevops/__init__.py b/src/main/python/ddadevops/__init__.py index fe527a8..bc8c0b0 100644 --- a/src/main/python/ddadevops/__init__.py +++ b/src/main/python/ddadevops/__init__.py @@ -6,6 +6,6 @@ terraform, dda-pallet, aws & hetzner-cloud. from .meissa_build import meissa_init_project, stage, hetzner_api_key, tf_import_name, tf_import_resource from .dda_pallet import dda_write_target, dda_uberjar -from .terraform import tf_copy_common, tf_plan, tf_import, tf_apply, tf_destroy, tf_read_output_json +from .terraform import tf_copy_common, tf_plan, tf_import, tf_apply, tf_output, tf_destroy, tf_read_output_json __version__ = "${version}" \ No newline at end of file diff --git a/src/main/python/ddadevops/terraform.py b/src/main/python/ddadevops/terraform.py index 54dd846..dcaeaa5 100644 --- a/src/main/python/ddadevops/terraform.py +++ b/src/main/python/ddadevops/terraform.py @@ -34,13 +34,18 @@ def tf_import(project): def tf_apply(project, auto_approve=None): init(project) - cmd = [] tf = Terraform(working_dir='.') if auto_approve: tf.apply(capture_output=False, auto_approve=True, var=get_hetzner_api_key_as_dict(project)) else: tf.apply(capture_output=False, var=get_hetzner_api_key_as_dict(project)) - tf.output(json=IsFlagged) + tf_output(project) + +def tf_output(project): + tf = Terraform(working_dir='.') + result = tf.output(json=IsFlagged) + with open(OUTPUT_JSON, "w") as output_file: + output_file.write(json.dumps(result)) def tf_destroy(project, auto_approve=None): tf = Terraform(working_dir='.')