Skip to content

Commit

Permalink
fix: pass dirs_exist_ok=True to shutil.copytree()
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Mar 7, 2025
1 parent dd647a9 commit 162c642
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/claranet_tfwrapper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,10 @@ def bootstrap(wrapper_config):
else:
template = "{}/basic".format(stack_type)

# shutil.copytree()'s dirs_exist_ok is new in python 3.8
if os.path.isdir(stack_path):
os.rmdir(stack_path)
template_path = template if os.path.isdir(template) else f"{rootdir}/templates/{template}"
shutil.copytree(template_path, stack_path, ignore=shutil.ignore_patterns("state.tf", ".terraform"))
shutil.copytree(
template_path, stack_path, ignore=shutil.ignore_patterns("state.tf", ".terraform"), dirs_exist_ok=True
)
logger.info("Bootstrapped stack using template {}.".format(template))
else:
logger.info("No template specified and no cloud provider defined in configuration, skipping.")
Expand Down

0 comments on commit 162c642

Please sign in to comment.