tgwrap 0.10.2__py3-none-any.whl → 0.10.3__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/cli.py +3 -3
- tgwrap/main.py +31 -5
- {tgwrap-0.10.2.dist-info → tgwrap-0.10.3.dist-info}/METADATA +1 -1
- {tgwrap-0.10.2.dist-info → tgwrap-0.10.3.dist-info}/RECORD +7 -7
- {tgwrap-0.10.2.dist-info → tgwrap-0.10.3.dist-info}/LICENSE +0 -0
- {tgwrap-0.10.2.dist-info → tgwrap-0.10.3.dist-info}/WHEEL +0 -0
- {tgwrap-0.10.2.dist-info → tgwrap-0.10.3.dist-info}/entry_points.txt +0 -0
tgwrap/cli.py
CHANGED
@@ -120,7 +120,7 @@ def main():
|
|
120
120
|
help='dry-run mode, no real actions are executed (only in combination with step-by-step mode)',
|
121
121
|
show_default=True
|
122
122
|
)
|
123
|
-
@click.option('--no-lock', '-n', is_flag=True, default=
|
123
|
+
@click.option('--no-lock', '-n', is_flag=True, default=True,
|
124
124
|
help='Do not apply a lock while executing the command (or set the TGWRAP_NO_LOCK environment variable, only applicable with plan)',
|
125
125
|
envvar='TGWRAP_NO_LOCK', show_default=True,
|
126
126
|
)
|
@@ -189,7 +189,7 @@ def run(command, verbose, debug, dry_run, no_lock, update, upgrade,
|
|
189
189
|
help='dry-run mode, no real actions are executed (only in combination with step-by-step mode)',
|
190
190
|
show_default=True
|
191
191
|
)
|
192
|
-
@click.option('--no-lock', '-n', is_flag=True, default=
|
192
|
+
@click.option('--no-lock', '-n', is_flag=True, default=True,
|
193
193
|
help='Do not apply a lock while executing the command (or set the TGWRAP_NO_LOCK environment variable, only applicable with plan)',
|
194
194
|
envvar='TGWRAP_NO_LOCK', show_default=True,
|
195
195
|
)
|
@@ -335,7 +335,7 @@ def show(verbose, json, working_dir, planfile_dir, terragrunt_args):
|
|
335
335
|
@click.option('--working-dir', '-w', default=None,
|
336
336
|
help='Working directory, when omitted the current directory is used',
|
337
337
|
)
|
338
|
-
@click.option('--no-lock', '-n', is_flag=True, default=
|
338
|
+
@click.option('--no-lock', '-n', is_flag=True, default=True,
|
339
339
|
help='Do not apply a lock while executing the command (or set the TGWRAP_NO_LOCK environment variable, only applicable with plan)',
|
340
340
|
envvar='TGWRAP_NO_LOCK', show_default=True,
|
341
341
|
)
|
tgwrap/main.py
CHANGED
@@ -222,9 +222,12 @@ class TgWrap():
|
|
222
222
|
include_dirs = [dir.lstrip(f'.{os.path.sep}') for dir in include_dirs]
|
223
223
|
exclude_dirs = [dir.lstrip(f'.{os.path.sep}') for dir in exclude_dirs]
|
224
224
|
|
225
|
+
# Below doesn't seem to work, at least when using `analyze`
|
226
|
+
# Not sure it has been added here in the first place
|
227
|
+
|
225
228
|
# if the dir is not ending on '/*', add it
|
226
|
-
include_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in include_dirs]
|
227
|
-
exclude_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in exclude_dirs]
|
229
|
+
# include_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in include_dirs]
|
230
|
+
# exclude_dirs = [dir.rstrip(f'.{os.path.sep}*') + f'{os.path.sep}*' for dir in exclude_dirs]
|
228
231
|
|
229
232
|
common_path = os.path.commonpath([os.path.abspath(working_dir), os.path.abspath(directory)])
|
230
233
|
self.printer.verbose(f'Common path for dir {directory}: {common_path}')
|
@@ -961,6 +964,25 @@ class TgWrap():
|
|
961
964
|
planfile, auto_approve, clean, working_dir, terragrunt_args):
|
962
965
|
""" Executes a terragrunt command on a single module """
|
963
966
|
|
967
|
+
def extract_source_value(terragrunt_file_content):
|
968
|
+
# Regular expression to capture the terraform block
|
969
|
+
terraform_block_pattern = re.compile(r'terraform\s*\{(.*?)\n\}', re.DOTALL)
|
970
|
+
|
971
|
+
# Regular expression to capture the 'source' key and its value
|
972
|
+
source_pattern = re.compile(r'source\s*=\s*"(.*?)(?<!\\)"', re.DOTALL)
|
973
|
+
|
974
|
+
# Find the terraform block
|
975
|
+
terraform_block_match = terraform_block_pattern.search(terragrunt_file_content)
|
976
|
+
if terraform_block_match:
|
977
|
+
terraform_block = terraform_block_match.group(1)
|
978
|
+
|
979
|
+
# Search for the 'source' key within the block
|
980
|
+
source_match = source_pattern.search(terraform_block)
|
981
|
+
if source_match:
|
982
|
+
return source_match.group(1) # Return the value of 'source'
|
983
|
+
else:
|
984
|
+
raise ValueError('Could not locate the terragrunt source value')
|
985
|
+
|
964
986
|
self.printer.verbose(f"Attempting to execute 'run {command}'")
|
965
987
|
if terragrunt_args:
|
966
988
|
self.printer.verbose(f"- with additional parameters: {' '.join(terragrunt_args)}")
|
@@ -968,6 +990,7 @@ class TgWrap():
|
|
968
990
|
check_for_file=self.TERRAGRUNT_FILE
|
969
991
|
if working_dir:
|
970
992
|
check_for_file = os.path.join(working_dir, check_for_file)
|
993
|
+
|
971
994
|
if not os.path.isfile(check_for_file):
|
972
995
|
self.printer.error(
|
973
996
|
f"{check_for_file} not found, this seems not to be a terragrunt module directory!"
|
@@ -978,13 +1001,15 @@ class TgWrap():
|
|
978
1001
|
source_module = None
|
979
1002
|
with open(check_for_file, 'r') as file:
|
980
1003
|
try:
|
981
|
-
content =
|
982
|
-
source = content
|
1004
|
+
content = file.read()
|
1005
|
+
source = extract_source_value(content)
|
1006
|
+
|
983
1007
|
# get the source part, typically the last part after the double /.
|
984
1008
|
# also remove a potential version element from it.
|
985
1009
|
source_module = re.sub(r'\${[^}]*}', '', source.split('//')[::-1][0])
|
986
1010
|
except Exception as e:
|
987
|
-
self.printer.
|
1011
|
+
self.printer.warning(f'Could not parse terragrunt.hcl, but we fall back to default behaviour.')
|
1012
|
+
self.printer.verbose(f'error (of type {type(e)}) raised')
|
988
1013
|
pass
|
989
1014
|
|
990
1015
|
cmd = self._construct_command(
|
@@ -1673,6 +1698,7 @@ class TgWrap():
|
|
1673
1698
|
for location in result:
|
1674
1699
|
# Determine the deployed version as defined in the version file
|
1675
1700
|
with open(os.path.join(working_dir, location, self.VERSION_FILE), 'r') as file:
|
1701
|
+
# todo: replace this with regex as it is (now) the only reason we use this lib
|
1676
1702
|
content = hcl2.load(file)
|
1677
1703
|
try:
|
1678
1704
|
version_tag = content['locals'][0]['version_tag']
|
@@ -1,13 +1,13 @@
|
|
1
1
|
tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
tgwrap/analyze.py,sha256=TJvAKVIbWl8-8oxpTwXVBWU72q_XQKzUTlyMZ25cV2M,8728
|
3
|
-
tgwrap/cli.py,sha256=
|
3
|
+
tgwrap/cli.py,sha256=3tf-wi-zN6T_0T2fHt8UtWzoZeUwlraGWsu5BduYxs4,31646
|
4
4
|
tgwrap/deploy.py,sha256=-fSk-Ix_HqrXY7KQX_L27TnFzIuhBHYv4xYJW6zRDN4,10243
|
5
5
|
tgwrap/inspector-resources-template.yml,sha256=Mos8NDzzZ3VxdXgeiVL9cmQfRcIXIHMLf79_KLwdXu8,3297
|
6
6
|
tgwrap/inspector.py,sha256=5pW7Ex1lkKRoXY6hZGbCNmSD2iRzgMSfqi9w7gb-AcY,16990
|
7
|
-
tgwrap/main.py,sha256=
|
7
|
+
tgwrap/main.py,sha256=Ggnb9S1GbsZUzg4TW_9xUhK2ZaZUCoAWX6oBteRu4O4,90012
|
8
8
|
tgwrap/printer.py,sha256=frn1PARd8A28mkRCYR6ybN2x0NBULhNOutn4l2U7REY,2754
|
9
|
-
tgwrap-0.10.
|
10
|
-
tgwrap-0.10.
|
11
|
-
tgwrap-0.10.
|
12
|
-
tgwrap-0.10.
|
13
|
-
tgwrap-0.10.
|
9
|
+
tgwrap-0.10.3.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
|
10
|
+
tgwrap-0.10.3.dist-info/METADATA,sha256=K47ImnV2gqCBkW6ARwFyuNiAJWJkyGEyxiUZXeIXJmc,17476
|
11
|
+
tgwrap-0.10.3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
12
|
+
tgwrap-0.10.3.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
|
13
|
+
tgwrap-0.10.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|