55import uuid
66
77from gitopscli .git .create_git import create_git
8- from gitopscli .yaml .gitops_config import GitOpsConfig
9- from gitopscli .yaml .yaml_util import update_yaml_file
8+ from gitopscli .io .gitops_config import GitOpsConfig
9+ from gitopscli .io .yaml_util import update_yaml_file
10+ from gitopscli .io .tmp_dir import create_tmp_dir , delete_tmp_dir
1011from gitopscli .gitops_exception import GitOpsException
1112
1213# pylint: disable=too-many-statements
@@ -29,8 +30,8 @@ def create_preview_command(
2930):
3031 assert command == "create-preview"
3132
32- apps_tmp_dir = __create_tmp_dir ()
33- root_tmp_dir = __create_tmp_dir ()
33+ apps_tmp_dir = create_tmp_dir ()
34+ root_tmp_dir = create_tmp_dir ()
3435
3536 try :
3637 apps_git = create_git (
@@ -127,8 +128,8 @@ def create_preview_command(
127128 logging .info ("Creating PullRequest comment for pr with id %s and content: %s" , pr_id , pr_comment_text )
128129 apps_git .add_pull_request_comment (pr_id , pr_comment_text , parent_id )
129130 finally :
130- shutil . rmtree (apps_tmp_dir , ignore_errors = True )
131- shutil . rmtree (root_tmp_dir , ignore_errors = True )
131+ delete_tmp_dir (apps_tmp_dir )
132+ delete_tmp_dir (root_tmp_dir )
132133 if create_pr :
133134 pull_request = __create_pullrequest (config_branch , gitops_config , root_git )
134135 if auto_merge :
@@ -207,10 +208,3 @@ def __merge_pullrequest(branch, pull_request, root_git):
207208 logging .info ("Pull request merged" )
208209 root_git .delete_branch (branch )
209210 logging .info ("Branch '%s' deleted" , branch )
210-
211-
212- def __create_tmp_dir ():
213- tmp_dir = f"/tmp/gitopscli/{ uuid .uuid4 ()} "
214- os .makedirs (tmp_dir )
215- logging .info ("Created directory %s" , tmp_dir )
216- return tmp_dir
0 commit comments