Skip to content

Commit f4ddc42

Browse files
committed
Use symlinks instead of copying files around
1 parent 6169fcb commit f4ddc42

13 files changed

+22
-1058
lines changed

helpers/generate_modules/generate_modules.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,22 @@ def root_outputs_tf(outputs):
101101
return buf
102102

103103

104-
def _copy_recursively(src, dest):
104+
def _copy_recursively_with_symlinks(src, dest):
105105
for node in os.listdir(src):
106106
src_path = os.path.join(src, node)
107107
dest_path = os.path.join(dest, node)
108108
if os.path.isdir(src_path):
109109
if not os.path.exists(dest_path):
110110
os.mkdir(dest_path)
111-
_copy_recursively(src_path, dest_path)
111+
_copy_recursively_with_symlinks(src_path, dest_path)
112112
elif os.path.isfile(src_path):
113-
shutil.copyfile(src_path, dest_path)
113+
abs_src_path = os.path.abspath(src_path)
114+
abs_dest_path = os.path.dirname(os.path.abspath(dest_path))
115+
relative_path = os.path.relpath(abs_src_path, abs_dest_path)
116+
try:
117+
os.symlink(relative_path, dest_path)
118+
except OSError:
119+
print("Skipping" + dest_path)
114120

115121

116122
def create_submodules():
@@ -119,7 +125,7 @@ def create_submodules():
119125
modules = next(os.walk("./modules"))[1]
120126
for module in modules:
121127
dest_folder = os.path.join("./modules", module)
122-
_copy_recursively("./autogen", dest_folder)
128+
_copy_recursively_with_symlinks("./autogen", dest_folder)
123129

124130

125131
def create_root_module_wrapper():

modules/public-cluster/auth.tf

Lines changed: 0 additions & 30 deletions
This file was deleted.

modules/public-cluster/auth.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../autogen/auth.tf

modules/public-cluster/cluster_regional.tf

Lines changed: 0 additions & 154 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../autogen/cluster_regional.tf

modules/public-cluster/cluster_zonal.tf

Lines changed: 0 additions & 154 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../autogen/cluster_zonal.tf

0 commit comments

Comments
 (0)