From 749bec79e43cf4bf210d01299f89f16174eb2c9e Mon Sep 17 00:00:00 2001 From: DJDavisson Date: Fri, 3 May 2019 13:59:48 -0700 Subject: [PATCH] Adding additional workspace items. --- python_terraform/__init__.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/python_terraform/__init__.py b/python_terraform/__init__.py index e5d31db..d554019 100644 --- a/python_terraform/__init__.py +++ b/python_terraform/__init__.py @@ -399,10 +399,35 @@ class Terraform(object): """ options = kwargs - options['workspace'] = workspace options = self._generate_default_options(options) args = self._generate_default_args(dir_or_plan) - return self.cmd('workspace', *args, **options) + return self.cmd('workspace select ' + workspace, *args, **options) + + def create_workspace(self, workspace=None, dir_or_plan=None, **kwargs): + """ + set workspace + :param workspace: the desired workspace. + :param dir: The dir we want to swap workspace in. + :return: nothing + """ + + options = kwargs + options = self._generate_default_options(options) + args = self._generate_default_args(dir_or_plan) + return self.cmd('workspace new ' + workspace, *args, **options) + + def show_workspace(self, workspace=None, dir_or_plan=None, **kwargs): + """ + set workspace + :param workspace: the desired workspace. + :param dir: The dir we want to swap workspace in. + :return: nothing + """ + + options = kwargs + options = self._generate_default_options(options) + args = self._generate_default_args(dir_or_plan) + return self.cmd('workspace show', *args, **options) def __exit__(self, exc_type, exc_value, traceback): self.temp_var_files.clean_up()