make workspaces configurable

This commit is contained in:
jem 2020-03-04 09:24:17 +01:00
parent f8dd897158
commit ac9c4ab104
2 changed files with 11 additions and 7 deletions

View file

@ -27,7 +27,7 @@ use_plugin("python.distutils")
default_task = "publish" default_task = "publish"
name = "ddadevops" name = "ddadevops"
version = "0.4.0.dev10" version = "0.4.0.dev12"
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

@ -10,13 +10,15 @@ def create_devops_terraform_build_config(stage, project_root_path, build_commons
account_name, additional_vars, account_name, additional_vars,
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):
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({'account_name': account_name, ret.update({'account_name': account_name,
'additional_vars': additional_vars, '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})
return ret return ret
@ -27,6 +29,7 @@ class DevopsTerraformBuild(DevopsBuild):
self.additional_vars = config['additional_vars'] self.additional_vars = config['additional_vars']
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']
def terraform_build_commons_path(self): def terraform_build_commons_path(self):
mylist = [self.build_commons_path, mylist = [self.build_commons_path,
@ -52,10 +55,11 @@ class DevopsTerraformBuild(DevopsBuild):
def init_client(self): def init_client(self):
tf = Terraform(working_dir=self.build_path()) tf = Terraform(working_dir=self.build_path())
tf.init() tf.init()
try: if self.use_workspace:
tf.workspace('select', slef.stage) try:
except: tf.workspace('select', slef.stage)
tf.workspace('new', self.stage) except:
tf.workspace('new', self.stage)
return tf return tf
def write_output(self, tf): def write_output(self, tf):