@@ -49,7 +49,8 @@ def __init__(self, working_dir=None,
4949 parallelism = None ,
5050 var_file = None ,
5151 terraform_bin_path = None ,
52- is_env_vars_included = True ):
52+ is_env_vars_included = True ,
53+ ):
5354 """
5455 :param working_dir: the folder of the working folder, if not given,
5556 will be current working folder
@@ -387,6 +388,41 @@ def read_state_file(self, file_path=None):
387388
388389 self .tfstate = Tfstate .load_file (file_path )
389390
391+ def set_workspace (self , workspace ):
392+ """
393+ set workspace
394+ :param workspace: the desired workspace.
395+ :return: status
396+ """
397+
398+ return self .cmd ('workspace' ,'select' , workspace )
399+
400+ def create_workspace (self , workspace ):
401+ """
402+ create workspace
403+ :param workspace: the desired workspace.
404+ :return: status
405+ """
406+
407+ return self .cmd ('workspace' , 'new' , workspace )
408+
409+ def delete_workspace (self , workspace ):
410+ """
411+ delete workspace
412+ :param workspace: the desired workspace.
413+ :return: status
414+ """
415+
416+ return self .cmd ('workspace' , 'delete' , workspace )
417+
418+ def show_workspace (self ):
419+ """
420+ show workspace
421+ :return: workspace
422+ """
423+
424+ return self .cmd ('workspace' , 'show' )
425+
390426 def __exit__ (self , exc_type , exc_value , traceback ):
391427 self .temp_var_files .clean_up ()
392428
@@ -396,7 +432,7 @@ def __init__(self):
396432 self .files = []
397433
398434 def create (self , variables ):
399- with tempfile .NamedTemporaryFile ('w+t' , delete = False ) as temp :
435+ with tempfile .NamedTemporaryFile ('w+t' , suffix = '.tfvars.json' , delete = False ) as temp :
400436 log .debug ('{0} is created' .format (temp .name ))
401437 self .files .append (temp )
402438 log .debug (
0 commit comments