kapicorp / kapitan

Generic templated configuration management for Kubernetes, Terraform and other things
https://kapitan.dev
Apache License 2.0
1.83k stars 200 forks source link

Fix `utils.copy_tree()` to create `dst` if it doesn't exist #1231

Closed simu closed 1 month ago

simu commented 2 months ago

Proposed Changes

Kapitan's utils.copy_tree() calls shutil.copytree() which will create the destination directory if it doesn't exist yet. However, currently, utils.copy_tree() doesn't support this case and will raise a SafeCopyError when the destination directory doesn't exist.

This PR adjusts the implementation to only raise a SafeCopyError when the destination exists and isn't a directory and will let shutil.copytree() create the destination if the destination doesn't exist at all.

Docs and Tests