tgwrap 0.11.2__py3-none-any.whl → 0.11.4__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/analyze.py CHANGED
@@ -34,6 +34,7 @@ def run_analyze(config, data, ignore_attributes, verbose=False):
34
34
 
35
35
  detected_changes = get_resource_actions(data)
36
36
 
37
+ ignorable_updates = []
37
38
  if config:
38
39
  ts_default_levels = {
39
40
  'low': 'ignore_deletion',
@@ -44,7 +45,6 @@ def run_analyze(config, data, ignore_attributes, verbose=False):
44
45
  for criticallity, ts_level in ts_default_levels.items():
45
46
  ts_config[ts_level] = [f"*{key}*" for key, value in config[criticallity].items() if value.get('terrasafe_level', ts_level) == ts_level]
46
47
 
47
- ignorable_updates = []
48
48
  for resource in detected_changes['updates']:
49
49
  before = resource['change']['before']
50
50
  after = resource['change']['after']
tgwrap/cli.py CHANGED
@@ -17,7 +17,7 @@ import click
17
17
 
18
18
  from outdated import check_outdated
19
19
 
20
- from .main import TgWrap
20
+ from .main import TgWrap, TG_COMMANDS, STAGES
21
21
 
22
22
  PACKAGE_NAME = 'tgwrap'
23
23
  try:
@@ -48,11 +48,6 @@ def check_latest_version(verbose=False):
48
48
 
49
49
  CLICK_CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
50
50
 
51
- TG_COMMANDS=[
52
- 'init', 'validate', 'validate-inputs', 'plan', 'apply',
53
- 'destroy', 'info', 'output', 'show', 'state', 'force-unlock'
54
- ]
55
- STAGES=['global', 'sbx', 'dev', 'qas', 'run', 'tst', 'acc', 'prd']
56
51
  class DefaultGroup(click.Group):
57
52
  '''
58
53
  Allow a default command for a group
@@ -546,8 +541,8 @@ def unlock(module, auto_approve, verbose, dry_run, working_dir):
546
541
  help='Clean up files on target side that do not exist as source',
547
542
  show_default=True
548
543
  )
549
- @click.option('--include-lock-file', '-i', is_flag=True, default=False,
550
- help='Include the terraform lock file',
544
+ @click.option('--include-dotenv-file', '-i', is_flag=True, default=False,
545
+ help='Include the .env (or .envrc) files',
551
546
  show_default=True
552
547
  )
553
548
  @click.option('--auto-approve', '-a', is_flag=True, default=False,
@@ -568,7 +563,7 @@ def unlock(module, auto_approve, verbose, dry_run, working_dir):
568
563
  @click.version_option(version=__version__)
569
564
  def sync(
570
565
  source_domain, source_stage, target_domain, target_stage, module, auto_approve,
571
- verbose, dry_run, clean, include_lock_file, working_dir
566
+ verbose, dry_run, clean, include_dotenv_file, working_dir
572
567
  ):
573
568
  """ Syncs the terragrunt config files from one stage to another (and possibly to a different domain) """
574
569
 
@@ -584,7 +579,7 @@ def sync(
584
579
  auto_approve=auto_approve,
585
580
  dry_run=dry_run,
586
581
  clean=clean,
587
- include_lock_file=include_lock_file,
582
+ include_dotenv_file=include_dotenv_file,
588
583
  working_dir=working_dir,
589
584
  )
590
585
 
@@ -604,8 +599,8 @@ def sync(
604
599
  help='Clean up files on target side that do not exist as source',
605
600
  show_default=True
606
601
  )
607
- @click.option('--include-lock-file', '-i', is_flag=True, default=False,
608
- help='Include the terraform lock file',
602
+ @click.option('--include-dotenv-file', '-i', is_flag=True, default=False,
603
+ help='Include the .env (or .envrc) files',
609
604
  show_default=True
610
605
  )
611
606
  @click.option('--auto-approve', '-a', is_flag=True, default=False,
@@ -626,7 +621,7 @@ def sync(
626
621
  @click.version_option(version=__version__)
627
622
  def sync_dir(
628
623
  source_directory, target_directory, auto_approve,
629
- verbose, dry_run, clean, include_lock_file, working_dir
624
+ verbose, dry_run, clean, include_dotenv_file, working_dir
630
625
  ):
631
626
  """ Syncs the terragrunt config files from one directory to anothery """
632
627
 
@@ -639,7 +634,7 @@ def sync_dir(
639
634
  auto_approve=auto_approve,
640
635
  dry_run=dry_run,
641
636
  clean=clean,
642
- include_lock_file=include_lock_file,
637
+ include_dotenv_file=include_dotenv_file,
643
638
  working_dir=working_dir,
644
639
  )
645
640
 
tgwrap/deploy.py CHANGED
@@ -10,7 +10,7 @@ import shlex
10
10
  from .printer import Printer
11
11
 
12
12
  def run_sync(
13
- source_path, target_path, auto_approve, include_lock_file, dry_run, clean, terragrunt_file,
13
+ source_path, target_path, auto_approve, include_dotenv_file, dry_run, clean, terragrunt_file,
14
14
  excludes=[], source_stage=None, target_stage=None, source_domain=None, verbose=False,
15
15
  ):
16
16
  """ Run a sync copying files from a source to a target path """
@@ -46,8 +46,8 @@ def run_sync(
46
46
  dry_run_stmt = '--dry-run' if dry_run else ''
47
47
  clean_stmt = '--delete' if clean else ''
48
48
  env_file_stmt = "--exclude='env.hcl'" if source_stage != target_stage else "--include='env.hcl'"
49
- lock_file_stmt = "--include='.terraform.lock.hcl'" if include_lock_file \
50
- else "--exclude='.terraform.lock.hcl'"
49
+ dotenv_file_stmt = "--include='.env' --include='.envrc'" if include_dotenv_file \
50
+ else "--exclude='.env' --exclude='.envrc'"
51
51
  excludes_stmt = ' '.join([f"--exclude={x}" for x in excludes])
52
52
 
53
53
  include_statements = ""
@@ -57,7 +57,7 @@ def run_sync(
57
57
  #
58
58
  if os.path.isdir(target_path):
59
59
  include_statements = \
60
- f"--include='{terragrunt_file}' {lock_file_stmt} {env_file_stmt} {excludes_stmt} " + \
60
+ f"--include='{terragrunt_file}' {dotenv_file_stmt} {env_file_stmt} {excludes_stmt} " + \
61
61
  "--exclude='.terragrunt-cache/' --exclude='.terraform/' " + \
62
62
  "--exclude='terragrunt-debug.tfvars.json' --exclude=planfile " + \
63
63
  "--exclude='.DS_Store' --exclude='*.log' "
tgwrap/main.py CHANGED
@@ -38,6 +38,35 @@ from .analyze import run_analyze
38
38
  from .deploy import prepare_deploy_config, run_sync
39
39
  from .inspector import AzureInspector
40
40
 
41
+ TG_COMMANDS=[
42
+ 'apply',
43
+ 'destroy',
44
+ 'exec',
45
+ 'force-unlock',
46
+ 'graph',
47
+ 'info',
48
+ 'init',
49
+ 'output',
50
+ 'plan',
51
+ 'run',
52
+ 'show',
53
+ 'state',
54
+ 'taint',
55
+ 'untaint',
56
+ 'validate-inputs',
57
+ 'validate',
58
+ ]
59
+ STAGES=[
60
+ 'global',
61
+ 'sbx',
62
+ 'dev',
63
+ 'qas',
64
+ 'run',
65
+ 'tst',
66
+ 'acc',
67
+ 'prd',
68
+ ]
69
+
41
70
  class DateTimeEncoder(json.JSONEncoder):
42
71
  def default(self, obj):
43
72
  if isinstance(obj, datetime):
@@ -1241,7 +1270,9 @@ class TgWrap():
1241
1270
  else:
1242
1271
  self.printer.verbose('Use native terraform for module selection')
1243
1272
  use_native_terraform = True
1244
- cmd = f"terraform show -json {self.PLANFILE_NAME}"
1273
+ # the 'tf' command is part of tenv and determines, based on the existence of .opentofu-version or .terraform-version
1274
+ # whether to use terraform or opentofu
1275
+ cmd = f"tf show -json {self.PLANFILE_NAME}"
1245
1276
 
1246
1277
  config = None
1247
1278
  if analyze_config:
@@ -1448,7 +1479,7 @@ class TgWrap():
1448
1479
 
1449
1480
  def sync(
1450
1481
  self, source_stage, target_stage, source_domain, target_domain, module,
1451
- auto_approve, dry_run, clean, include_lock_file, working_dir,
1482
+ auto_approve, dry_run, clean, include_dotenv_file, working_dir,
1452
1483
  ):
1453
1484
  """ Syncs the terragrunt config files from one stage to another (and possibly to a different domain) """
1454
1485
 
@@ -1476,7 +1507,7 @@ class TgWrap():
1476
1507
  source_domain=source_domain,
1477
1508
  source_stage=source_stage,
1478
1509
  target_stage=target_stage,
1479
- include_lock_file=include_lock_file,
1510
+ include_dotenv_file=include_dotenv_file,
1480
1511
  auto_approve=auto_approve,
1481
1512
  dry_run=dry_run,
1482
1513
  clean=clean,
@@ -1486,7 +1517,7 @@ class TgWrap():
1486
1517
 
1487
1518
  def sync_dir(
1488
1519
  self, source_directory, target_directory,
1489
- auto_approve, dry_run, clean, include_lock_file, working_dir,
1520
+ auto_approve, dry_run, clean, include_dotenv_file, working_dir,
1490
1521
  ):
1491
1522
  """ Syncs the terragrunt config files from one directory to anothery """
1492
1523
 
@@ -1499,10 +1530,10 @@ class TgWrap():
1499
1530
  run_sync(
1500
1531
  source_path=source_path,
1501
1532
  target_path=target_path,
1502
- include_lock_file=include_lock_file,
1503
1533
  auto_approve=auto_approve,
1504
1534
  dry_run=dry_run,
1505
1535
  clean=clean,
1536
+ include_dotenv_file=include_dotenv_file,
1506
1537
  terragrunt_file=self.TERRAGRUNT_FILE,
1507
1538
  verbose=self.printer.print_verbose,
1508
1539
  )
@@ -1590,6 +1621,7 @@ class TgWrap():
1590
1621
  source_path = os.path.join(
1591
1622
  source_dir, global_config['source']
1592
1623
  )
1624
+
1593
1625
  target = global_config.get('target', global_config['source'])
1594
1626
  target_path = os.path.dirname(
1595
1627
  os.path.join(
@@ -1625,7 +1657,7 @@ class TgWrap():
1625
1657
  source_path=value['source'],
1626
1658
  target_path=value['target'],
1627
1659
  excludes=value.get('excludes', []),
1628
- include_lock_file=True,
1660
+ include_dotenv_file=True,
1629
1661
  auto_approve=True,
1630
1662
  dry_run=dry_run,
1631
1663
  clean=False,
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: tgwrap
3
- Version: 0.11.2
3
+ Version: 0.11.4
4
4
  Summary: A (terragrunt) wrapper around a (terraform) wrapper around ....
5
- Home-page: https://gitlab.com/lunadata/tgwrap
6
5
  License: MIT
7
6
  Keywords: terraform,terragrunt,terrasafe,python
8
7
  Author: Gerco Grandia
@@ -26,6 +25,7 @@ Requires-Dist: python-hcl2 (>=4.3.2,<5.0.0)
26
25
  Requires-Dist: pyyaml (>=6.0)
27
26
  Requires-Dist: terrasafe (>=0.5.1,<0.6.0)
28
27
  Project-URL: Documentation, https://gitlab.com/lunadata/tgwrap/
28
+ Project-URL: Homepage, https://gitlab.com/lunadata/tgwrap
29
29
  Project-URL: Repository, https://gitlab.com/lunadata/tgwrap
30
30
  Description-Content-Type: text/markdown
31
31
 
@@ -0,0 +1,13 @@
1
+ tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ tgwrap/analyze.py,sha256=fuET7_L8b6rlv2qnKOYXSlIv5LArvZ39CPktCeQHo7A,10285
3
+ tgwrap/cli.py,sha256=IZuVHCR_9a40WRKpUCWOMVksUKzE_s2fzM26zbJ_N8o,32017
4
+ tgwrap/deploy.py,sha256=gwFdRDzJWjkmEzZ8b0GUSrgvJeOKnpnJm1c6mM80OcY,10259
5
+ tgwrap/inspector-resources-template.yml,sha256=Mos8NDzzZ3VxdXgeiVL9cmQfRcIXIHMLf79_KLwdXu8,3297
6
+ tgwrap/inspector.py,sha256=5pW7Ex1lkKRoXY6hZGbCNmSD2iRzgMSfqi9w7gb-AcY,16990
7
+ tgwrap/main.py,sha256=A8Xa1tWsaQgVjQG4VYZWouj0uoIwkMgXIm-prfmF0c8,94907
8
+ tgwrap/printer.py,sha256=frn1PARd8A28mkRCYR6ybN2x0NBULhNOutn4l2U7REY,2754
9
+ tgwrap-0.11.4.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
10
+ tgwrap-0.11.4.dist-info/METADATA,sha256=e6h-8JnVXLJDh3fILUO5_vDl90TIR0ii_P3PJPtNWNc,17698
11
+ tgwrap-0.11.4.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
12
+ tgwrap-0.11.4.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
13
+ tgwrap-0.11.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.1
2
+ Generator: poetry-core 2.0.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,13 +0,0 @@
1
- tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- tgwrap/analyze.py,sha256=5C0OcDpOfn6U39QNIoc7V9ePjjcXKbJH6cOVNr9jJ9A,10289
3
- tgwrap/cli.py,sha256=9zvBop3Gm5B2b8K-zXVHEvRUCC7t5ffZUJZEpj1Fxtw,32186
4
- tgwrap/deploy.py,sha256=-fSk-Ix_HqrXY7KQX_L27TnFzIuhBHYv4xYJW6zRDN4,10243
5
- tgwrap/inspector-resources-template.yml,sha256=Mos8NDzzZ3VxdXgeiVL9cmQfRcIXIHMLf79_KLwdXu8,3297
6
- tgwrap/inspector.py,sha256=5pW7Ex1lkKRoXY6hZGbCNmSD2iRzgMSfqi9w7gb-AcY,16990
7
- tgwrap/main.py,sha256=Vzmy9GEuBT-T6TB_ZzN_lET5ihY0P-9WcPZ_MPCus_k,94366
8
- tgwrap/printer.py,sha256=frn1PARd8A28mkRCYR6ybN2x0NBULhNOutn4l2U7REY,2754
9
- tgwrap-0.11.2.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
10
- tgwrap-0.11.2.dist-info/METADATA,sha256=fYWSDZfgDmERSCJ7ZOJqMmf7M6cdemNBjFg_jsUG5KQ,17686
11
- tgwrap-0.11.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
12
- tgwrap-0.11.2.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
13
- tgwrap-0.11.2.dist-info/RECORD,,