tgwrap 0.8.10__py3-none-any.whl → 0.8.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tgwrap/deploy.py +54 -51
- tgwrap/main.py +14 -4
- {tgwrap-0.8.10.dist-info → tgwrap-0.8.12.dist-info}/METADATA +4 -2
- tgwrap-0.8.12.dist-info/RECORD +11 -0
- tgwrap-0.8.10.dist-info/RECORD +0 -11
- {tgwrap-0.8.10.dist-info → tgwrap-0.8.12.dist-info}/LICENSE +0 -0
- {tgwrap-0.8.10.dist-info → tgwrap-0.8.12.dist-info}/WHEEL +0 -0
- {tgwrap-0.8.10.dist-info → tgwrap-0.8.12.dist-info}/entry_points.txt +0 -0
tgwrap/deploy.py
CHANGED
@@ -171,66 +171,69 @@ def prepare_deploy_config(step, config, source_dir, source_config_dir, target_di
|
|
171
171
|
printer.warning(f'Source path of config file does not exist: {source_path}')
|
172
172
|
|
173
173
|
for ss, substack in substack_configs:
|
174
|
-
|
175
|
-
|
176
|
-
source_path = os.path.join(
|
177
|
-
source_dir, source_stage, substack['source'], ''
|
178
|
-
)
|
179
|
-
target_path = os.path.join(
|
180
|
-
target_dir, substack['target'], ''
|
181
|
-
)
|
182
|
-
|
183
|
-
include_modules = substack['include_modules'] if len(substack.get('include_modules', {})) > 0 else []
|
184
|
-
printer.verbose(f'Include modules: {include_modules}')
|
185
|
-
|
186
|
-
if include_modules:
|
187
|
-
# get all directories in the substack and create an exlude_modules list from that
|
188
|
-
source_directories = get_directories(source_path)
|
189
|
-
exclude_modules = list(set(source_directories) - set(include_modules))
|
190
|
-
else:
|
191
|
-
exclude_modules = substack.get('exclude_modules', [])
|
192
|
-
|
193
|
-
if os.path.exists(source_path):
|
194
|
-
deploy_actions[f'substack -> {substack["target"]}'] = {
|
195
|
-
"source": source_path,
|
196
|
-
"target": target_path,
|
197
|
-
"excludes": exclude_modules,
|
198
|
-
}
|
174
|
+
if 'applies_to_stages' in substack and target_stage not in substack['applies_to_stages']:
|
175
|
+
printer.verbose(f'Target stage {target_stage} not applicable for substack {ss}.')
|
199
176
|
else:
|
200
|
-
printer.
|
201
|
-
|
202
|
-
if len(substack.get('configs', [])) > 0:
|
203
|
-
# run some checks and sets some variables
|
204
|
-
if not source_config_dir:
|
205
|
-
raise Exception("Config files must be deployed but 'config_path' variable is not set!")
|
206
|
-
elif not config_dir:
|
207
|
-
raise Exception("Config files must be deployed but 'config_dir' variable is not set!")
|
177
|
+
printer.verbose(f'Found substack : {ss}')
|
208
178
|
|
179
|
+
source_path = os.path.join(
|
180
|
+
source_dir, source_stage, substack['source'], ''
|
181
|
+
)
|
209
182
|
target_path = os.path.join(
|
210
|
-
target_dir,
|
183
|
+
target_dir, substack['target'], ''
|
211
184
|
)
|
212
|
-
# the target path might not exist
|
213
|
-
try:
|
214
|
-
os.makedirs(target_path)
|
215
|
-
except FileExistsError:
|
216
|
-
pass
|
217
185
|
|
218
|
-
|
219
|
-
printer.verbose(f'
|
186
|
+
include_modules = substack['include_modules'] if len(substack.get('include_modules', {})) > 0 else []
|
187
|
+
printer.verbose(f'Include modules: {include_modules}')
|
220
188
|
|
221
|
-
|
222
|
-
|
223
|
-
)
|
189
|
+
if include_modules:
|
190
|
+
# get all directories in the substack and create an exlude_modules list from that
|
191
|
+
source_directories = get_directories(source_path)
|
192
|
+
exclude_modules = list(set(source_directories) - set(include_modules))
|
193
|
+
else:
|
194
|
+
exclude_modules = substack.get('exclude_modules', [])
|
224
195
|
|
225
|
-
full_target_path = os.path.dirname(os.path.join(target_path, cfg))
|
226
|
-
# print("source: ", full_source_path)
|
227
|
-
# print("target: ", full_target_path)
|
228
196
|
if os.path.exists(source_path):
|
229
|
-
deploy_actions[f
|
230
|
-
"source":
|
231
|
-
"target":
|
197
|
+
deploy_actions[f'substack -> {substack["target"]}'] = {
|
198
|
+
"source": source_path,
|
199
|
+
"target": target_path,
|
200
|
+
"excludes": exclude_modules,
|
232
201
|
}
|
233
202
|
else:
|
234
|
-
printer.warning(f'Source path of
|
203
|
+
printer.warning(f'Source path of substack does not exist: {source_path}')
|
204
|
+
|
205
|
+
if len(substack.get('configs', [])) > 0:
|
206
|
+
# run some checks and sets some variables
|
207
|
+
if not source_config_dir:
|
208
|
+
raise Exception("Config files must be deployed but 'config_path' variable is not set!")
|
209
|
+
elif not config_dir:
|
210
|
+
raise Exception("Config files must be deployed but 'config_dir' variable is not set!")
|
211
|
+
|
212
|
+
target_path = os.path.join(
|
213
|
+
target_dir, config_dir, module_name, target_stage, substack['target'], '',
|
214
|
+
)
|
215
|
+
# the target path might not exist
|
216
|
+
try:
|
217
|
+
os.makedirs(target_path)
|
218
|
+
except FileExistsError:
|
219
|
+
pass
|
220
|
+
|
221
|
+
for cfg in substack.get('configs', []):
|
222
|
+
printer.verbose(f'Found substack config file : {cfg}')
|
223
|
+
|
224
|
+
full_source_path = os.path.join(
|
225
|
+
source_config_dir, source_stage, substack['source'], cfg
|
226
|
+
)
|
227
|
+
|
228
|
+
full_target_path = os.path.dirname(os.path.join(target_path, cfg))
|
229
|
+
# print("source: ", full_source_path)
|
230
|
+
# print("target: ", full_target_path)
|
231
|
+
if os.path.exists(source_path):
|
232
|
+
deploy_actions[f"substack {substack['target']} configs -> {os.path.join(substack['source'], cfg)}"] = {
|
233
|
+
"source": full_source_path,
|
234
|
+
"target": full_target_path,
|
235
|
+
}
|
236
|
+
else:
|
237
|
+
printer.warning(f'Source path of config file does not exist: {source_path}')
|
235
238
|
|
236
239
|
return deploy_actions
|
tgwrap/main.py
CHANGED
@@ -159,6 +159,7 @@ class TgWrap():
|
|
159
159
|
parallelism_stmt = f'--terragrunt-parallelism {limit_parallelism}' if limit_parallelism else ''
|
160
160
|
include_dir_stmt = f'--terragrunt-strict-include --terragrunt-include-dir {" --terragrunt-include-dir ".join(include_dirs)}' if len(include_dirs) > 0 else ""
|
161
161
|
exclude_dir_stmt = f'--terragrunt-exclude-dir {" --terragrunt-exclude-dir ".join(exclude_dirs)}' if len(exclude_dirs) > 0 else ""
|
162
|
+
|
162
163
|
else:
|
163
164
|
base_command = 'terragrunt'
|
164
165
|
ignore_deps_stmt = ''
|
@@ -214,6 +215,10 @@ class TgWrap():
|
|
214
215
|
include_dirs = [dir.lstrip(f'.{os.path.sep}') for dir in include_dirs]
|
215
216
|
exclude_dirs = [dir.lstrip(f'.{os.path.sep}') for dir in exclude_dirs]
|
216
217
|
|
218
|
+
# if the dir is not ending on '/*', add it
|
219
|
+
include_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in include_dirs]
|
220
|
+
exclude_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in exclude_dirs]
|
221
|
+
|
217
222
|
common_path = os.path.commonpath([os.path.abspath(working_dir), os.path.abspath(directory)])
|
218
223
|
self.printer.verbose(f'Common path for dir {directory}: {common_path}')
|
219
224
|
|
@@ -898,6 +903,10 @@ class TgWrap():
|
|
898
903
|
modifying_command = (command.lower() in ['apply', 'destroy'])
|
899
904
|
auto_approve = auto_approve if modifying_command else True
|
900
905
|
|
906
|
+
# if the dir is not ending on '/*', add it
|
907
|
+
include_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in include_dirs]
|
908
|
+
exclude_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in exclude_dirs]
|
909
|
+
|
901
910
|
cmd = self._construct_command(
|
902
911
|
command=command,
|
903
912
|
allow_no_run_all=False,
|
@@ -1305,6 +1314,10 @@ class TgWrap():
|
|
1305
1314
|
# and make it unique
|
1306
1315
|
substacks = set(substacks)
|
1307
1316
|
|
1317
|
+
# the manifest file supports both `sub_stacks` and `substack` config name. Annoying to be a bit autistic when it comes to naming :-/
|
1318
|
+
substack_configs = manifest.get('sub_stacks', {})
|
1319
|
+
substack_configs.update(manifest.get('substacks', {}))
|
1320
|
+
|
1308
1321
|
for target_stage in target_stages:
|
1309
1322
|
target_dir = os.path.join(working_dir, '', target_stage)
|
1310
1323
|
self.printer.header(f'Deploy stage {target_stage} to {target_dir}...')
|
@@ -1328,7 +1341,7 @@ class TgWrap():
|
|
1328
1341
|
target_dir=target_dir,
|
1329
1342
|
target_stage=target_stage,
|
1330
1343
|
substacks=substacks,
|
1331
|
-
substack_configs=
|
1344
|
+
substack_configs=substack_configs.items(),
|
1332
1345
|
tg_file_name=self.TERRAGRUNT_FILE,
|
1333
1346
|
verbose=self.printer.print_verbose,
|
1334
1347
|
)
|
@@ -1568,9 +1581,6 @@ Note:
|
|
1568
1581
|
if terragrunt_args:
|
1569
1582
|
self.printer.verbose(f"- with additional parameters: {' '.join(terragrunt_args)}")
|
1570
1583
|
|
1571
|
-
# self.printer.verbose(f"Include dirs: {'; '.join(include_dirs)}")
|
1572
|
-
# self.printer.verbose(f"Exclude dirs: {'; '.join(exclude_dirs)}")
|
1573
|
-
|
1574
1584
|
"Runs the desired command in the directories as defined in the directed graph"
|
1575
1585
|
graph = self._get_di_graph(backwards=backwards, working_dir=working_dir)
|
1576
1586
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: tgwrap
|
3
|
-
Version: 0.8.
|
3
|
+
Version: 0.8.12
|
4
4
|
Summary: A (terragrunt) wrapper around a (terraform) wrapper around ....
|
5
5
|
Home-page: https://gitlab.com/lunadata/tgwrap
|
6
6
|
License: MIT
|
@@ -230,7 +230,7 @@ deploy: # which modules do you want to deploy
|
|
230
230
|
# - source: networking
|
231
231
|
# - target: networking-connected
|
232
232
|
|
233
|
-
|
233
|
+
substacks:
|
234
234
|
is01:
|
235
235
|
source: shared-integration/intsvc01
|
236
236
|
target: integration/is01
|
@@ -240,6 +240,8 @@ sub_stacks:
|
|
240
240
|
- my-ss-config.hcl
|
241
241
|
- ../my-ss-config-dir
|
242
242
|
is02:
|
243
|
+
applies_to_stages: # optional list of stages to include the substack in
|
244
|
+
- dev
|
243
245
|
source: shared-integration/intsvc01
|
244
246
|
target: integration/is02
|
245
247
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
tgwrap/analyze.py,sha256=CsSaGv-be6ATy36z9X7x00gpKY59soJys2VbIzD-tmg,8726
|
3
|
+
tgwrap/cli.py,sha256=weYPXnpZ1200L28tNGzVaO_GlX7wAdLn1nQZsHKpe3k,29060
|
4
|
+
tgwrap/deploy.py,sha256=bJiox_fz8JsoPreX4woW6-EqAebhpJWnKUVLVeGXkrI,10000
|
5
|
+
tgwrap/main.py,sha256=82f4Wc-jPczDpP4vCMeJeaF1CBfiDGizNy0KDw_iDZw,74720
|
6
|
+
tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
|
7
|
+
tgwrap-0.8.12.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
|
8
|
+
tgwrap-0.8.12.dist-info/METADATA,sha256=RGlxakJg0v5wKWoma5H3rip2BTJ7mcmbq41iazo-VVE,11616
|
9
|
+
tgwrap-0.8.12.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
10
|
+
tgwrap-0.8.12.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
|
11
|
+
tgwrap-0.8.12.dist-info/RECORD,,
|
tgwrap-0.8.10.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
tgwrap/analyze.py,sha256=CsSaGv-be6ATy36z9X7x00gpKY59soJys2VbIzD-tmg,8726
|
3
|
-
tgwrap/cli.py,sha256=weYPXnpZ1200L28tNGzVaO_GlX7wAdLn1nQZsHKpe3k,29060
|
4
|
-
tgwrap/deploy.py,sha256=oD-H1ojdcSQTbiQHs7BZP9NnbV_MDtlpJFaDRl2-KvU,9578
|
5
|
-
tgwrap/main.py,sha256=ltOAJaACSneLECgcCYzqwQuoJZZe88juoQOfwsFZzJA,74105
|
6
|
-
tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
|
7
|
-
tgwrap-0.8.10.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
|
8
|
-
tgwrap-0.8.10.dist-info/METADATA,sha256=8atooQVSQ-GQUIhZgTg_RxMDBci6F36fKGoPSgOJ5PQ,11529
|
9
|
-
tgwrap-0.8.10.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
10
|
-
tgwrap-0.8.10.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
|
11
|
-
tgwrap-0.8.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|