add debug output

This commit is contained in:
jem 2020-03-10 15:41:07 +01:00
parent b576d2a3e7
commit ec3fcfdf97
2 changed files with 14 additions and 10 deletions

View file

@ -27,7 +27,7 @@ use_plugin("python.distutils")
default_task = "publish" default_task = "publish"
name = "ddadevops" name = "ddadevops"
version = "0.4.1.dev8" version = "0.4.1.dev15"
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
description = __doc__ description = __doc__
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]

View file

@ -1,5 +1,5 @@
from os import path from os import path
from json import load from json import load, dumps
from subprocess import run from subprocess import run
from python_terraform import * from python_terraform import *
from .python_util import filter_none from .python_util import filter_none
@ -11,14 +11,15 @@ def create_devops_terraform_build_config(stage, project_root_path, build_commons
build_dir_name='target', build_dir_name='target',
terraform_build_commons_dir_name='terraform', terraform_build_commons_dir_name='terraform',
output_json_name='output.json', output_json_name='output.json',
use_workspace=True, print_terraform_command=False): use_workspace=True,
debug_print_terraform_command=False):
ret = create_devops_build_config( ret = create_devops_build_config(
stage, project_root_path, build_commons_path, module, build_dir_name) stage, project_root_path, build_commons_path, module, build_dir_name)
ret.update({'additional_vars': additional_vars, ret.update({'additional_vars': additional_vars,
'terraform_build_commons_dir_name': terraform_build_commons_dir_name, 'terraform_build_commons_dir_name': terraform_build_commons_dir_name,
'output_json_name': output_json_name, 'output_json_name': output_json_name,
'use_workspace': use_workspace 'use_workspace': use_workspace,
'print_terraform_command': print_terraform_command}) 'debug_print_terraform_command': debug_print_terraform_command})
return ret return ret
@ -31,7 +32,7 @@ class DevopsTerraformBuild(DevopsBuild):
self.terraform_build_commons_dir_name = config['terraform_build_commons_dir_name'] self.terraform_build_commons_dir_name = config['terraform_build_commons_dir_name']
self.output_json_name = config['output_json_name'] self.output_json_name = config['output_json_name']
self.use_workspace = config['use_workspace'] self.use_workspace = config['use_workspace']
self.print_terraform_command = config['print_terraform_command'] self.debug_print_terraform_command = config['debug_print_terraform_command']
def terraform_build_commons_path(self): def terraform_build_commons_path(self):
mylist = [self.build_commons_path, mylist = [self.build_commons_path,
@ -100,5 +101,8 @@ class DevopsTerraformBuild(DevopsBuild):
capture_output=False, var=self.project_vars()) capture_output=False, var=self.project_vars())
def print_terraform_command(self, operation): def print_terraform_command(self, operation):
if self.print_terraform_command: if self.debug_print_terraform_command:
print('cd ' + self.build_path() + ' && terraform ' + operation + self.project_vars()) output = 'cd ' + self.build_path() + ' && terraform ' + operation
for key, value in self.project_vars().items():
output = output + ' -var="' + key + '=' + value + '"'
print(output)