Removing optiosn and args pass from state stuff, state stuff doesn't take options or args.

This commit is contained in:
DJDavisson 2019-05-07 12:11:28 -07:00
parent 3ddab331f0
commit 01e3dbb05a
2 changed files with 11 additions and 17 deletions

View file

@ -389,40 +389,31 @@ class Terraform(object):
self.tfstate = Tfstate.load_file(file_path) self.tfstate = Tfstate.load_file(file_path)
def set_workspace(self, workspace=None, dir_or_plan=None, **kwargs): def set_workspace(self, workspace):
""" """
set workspace set workspace
:param workspace: the desired workspace. :param workspace: the desired workspace.
:return: status :return: status
""" """
options = kwargs return self.cmd('workspace select ' + workspace)
options = self._generate_default_options(options)
args = self._generate_default_args(dir_or_plan)
return self.cmd('workspace select ' + workspace, *args, **options)
def create_workspace(self, workspace=None, dir_or_plan=None, **kwargs): def create_workspace(self, workspace):
""" """
create workspace create workspace
:param workspace: the desired workspace. :param workspace: the desired workspace.
:return: status :return: status
""" """
options = kwargs return self.cmd('workspace new ' + workspace)
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, dir_or_plan=None, **kwargs): def show_workspace(self):
""" """
show workspace show workspace
:return: workspace :return: workspace
""" """
options = kwargs return self.cmd('workspace show')
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): def __exit__(self, exc_type, exc_value, traceback):
self.temp_var_files.clean_up() self.temp_var_files.clean_up()

View file

@ -323,12 +323,14 @@ class TestTerraform(object):
def test_create_workspace(self): def test_create_workspace(self):
tf = Terraform(working_dir=current_path) tf = Terraform(working_dir=current_path)
tf.init()
ret, out, err = tf.create_workspace('test') ret, out, err = tf.create_workspace('test')
assert ret == 0 assert ret == 0
assert err == '' assert err == ''
def test_set_workspace(self): def test_set_workspace(self):
tf = Terraform(working_dir=current_path) tf = Terraform(working_dir=current_path)
tf.init()
tf.create_workspace('test') tf.create_workspace('test')
ret, out, err = tf.set_workspace('test') ret, out, err = tf.set_workspace('test')
assert ret == 0 assert ret == 0
@ -336,7 +338,8 @@ class TestTerraform(object):
def test_show_workspace(self): def test_show_workspace(self):
tf = Terraform(working_dir=current_path) tf = Terraform(working_dir=current_path)
tf.init()
tf.create_workspace('test') tf.create_workspace('test')
ret, out, err = tf.show_workspace('test') ret, out, err = tf.show_workspace()
assert ret == 0 assert ret == 0
assert err == '' assert err == ''