tgwrap 0.8.6__py3-none-any.whl → 0.8.8__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/main.py CHANGED
@@ -391,48 +391,53 @@ class TgWrap():
391
391
  # remove empty strings
392
392
  tags = [tag for tag in tags if tag != ""]
393
393
 
394
- if not tags:
395
- raise Exception('Could not load tags in source repository, cannot deploy without it.')
394
+ tags.insert(0, self.LATEST_VERSION)
396
395
 
397
396
  return tags
398
397
 
399
398
  def check_version_tag(reference, working_dir):
399
+ is_latest = (reference == self.LATEST_VERSION)
400
400
  is_branch = False
401
- quiet_mode = "" if self.printer.print_verbose else "--quiet"
402
-
403
- # Check if the given reference is a tag
404
- tag_command = f'git show-ref --verify {quiet_mode} refs/tags/{reference}'
405
- tag_process = subprocess.run(
406
- shlex.split(tag_command),
407
- cwd=working_dir,
408
- capture_output=True,
409
- )
410
- is_tag = tag_process.returncode == 0
411
- self.printer.verbose(f'Check for tag: {tag_process}')
412
-
413
- # if it is not a tag, then it might be a branch
414
- if not is_tag:
415
- branch_command = f'git switch {reference}'
416
- branch_process = subprocess.run(
417
- shlex.split(branch_command),
401
+ is_tag = False
402
+
403
+ if not is_latest:
404
+ quiet_mode = "" if self.printer.print_verbose else "--quiet"
405
+
406
+ # Check if the given reference is a tag
407
+ tag_command = f'git show-ref --verify {quiet_mode} refs/tags/{reference}'
408
+ tag_process = subprocess.run(
409
+ shlex.split(tag_command),
418
410
  cwd=working_dir,
419
411
  capture_output=True,
420
412
  )
421
- is_branch = branch_process.returncode == 0
422
- self.printer.verbose(f'Check for branch: {branch_process}')
413
+ is_tag = tag_process.returncode == 0
414
+ self.printer.verbose(f'Check for tag: {tag_process}')
415
+
416
+ # if it is not a tag, then it might be a branch
417
+ if not is_tag:
418
+ branch_command = f'git switch {reference}'
419
+ branch_process = subprocess.run(
420
+ shlex.split(branch_command),
421
+ cwd=working_dir,
422
+ capture_output=True,
423
+ )
424
+ is_branch = branch_process.returncode == 0
425
+ self.printer.verbose(f'Check for branch: {branch_process}')
423
426
 
424
427
  # Print the result
425
- if is_branch:
428
+ if is_latest:
429
+ self.printer.verbose(f"The given reference '{reference}' is the latest version.")
430
+ elif is_branch:
426
431
  self.printer.verbose(f"The given reference '{reference}' is a branch.")
427
432
  elif is_tag:
428
433
  self.printer.verbose(f"The given reference '{reference}' is a tag.")
429
434
  else:
430
- msg = f"The given reference '{reference}' is neither a branch nor a tag."
431
- self.printer.verbose(f"The given reference '{reference}' is neither a branch nor a tag.")
435
+ msg = f"The given reference '{reference}' is neither latest, a branch nor a tag."
436
+ self.printer.verbose(msg)
432
437
  raise Exception(msg)
433
438
 
434
439
 
435
- return is_branch, is_tag
440
+ return is_latest, is_branch, is_tag
436
441
 
437
442
  # clone the repo
438
443
  repo = manifest['git_repository']
@@ -461,14 +466,16 @@ class TgWrap():
461
466
  self.printer.normal
462
467
 
463
468
  # first check if we have a tag or a branch
464
- is_branch, is_tag = check_version_tag(
469
+ is_latest, is_branch, is_tag = check_version_tag(
465
470
  reference=version_tag,
466
471
  working_dir=target_dir,
467
472
  )
468
473
 
469
474
  self.printer.header(f'Deploy using reference {version_tag}')
470
475
 
471
- if is_tag:
476
+ if is_latest:
477
+ pass # nothing to do, we already have latest
478
+ elif is_tag:
472
479
  cmd = f"git checkout -b source {version_tag}"
473
480
  rc = subprocess.run(
474
481
  shlex.split(cmd),
@@ -844,15 +851,20 @@ class TgWrap():
844
851
  if not planfile_dir:
845
852
  self.printer.verbose('Use terragrunt for showing plan')
846
853
 
847
- if json and '-json' not in terragrunt_args:
848
- terragrunt_args.append('-json')
854
+ # some environments raise the error: AttributeError: ‘tuple’ object has no attribute ‘append’
855
+ # so convert to a list to make it updateable
856
+ tg_args_list = list(terragrunt_args)
857
+
858
+ # first run a 'show' and write output to file
859
+ if '-json' not in tg_args_list:
860
+ tg_args_list.append('-json')
849
861
 
850
862
  cmd = self._construct_command(
851
863
  command='show',
852
864
  allow_no_run_all=True,
853
865
  exclude_external_dependencies=True,
854
866
  debug=False,
855
- terragrunt_args=terragrunt_args,
867
+ terragrunt_args=tg_args_list,
856
868
  )
857
869
  else:
858
870
  cwd = os.path.join(cwd, planfile_dir)
@@ -998,16 +1010,21 @@ class TgWrap():
998
1010
  self.printer.verbose('Use terragrunt for module selection')
999
1011
 
1000
1012
  use_native_terraform = False
1013
+
1014
+ # some environments raise the error: AttributeError: ‘tuple’ object has no attribute ‘append’
1015
+ # so convert to a list to make it updateable
1016
+ tg_args_list = list(terragrunt_args)
1017
+
1001
1018
  # first run a 'show' and write output to file
1002
- if '-json' not in terragrunt_args:
1003
- terragrunt_args.append('-json')
1019
+ if '-json' not in tg_args_list:
1020
+ tg_args_list.append('-json')
1004
1021
 
1005
1022
  cmd = self._construct_command(
1006
1023
  command='show',
1007
1024
  allow_no_run_all=True,
1008
1025
  exclude_external_dependencies=True,
1009
1026
  debug=False,
1010
- terragrunt_args=terragrunt_args,
1027
+ terragrunt_args=tg_args_list,
1011
1028
  )
1012
1029
  else:
1013
1030
  self.printer.verbose('Use native terraform for module selection')
@@ -1624,12 +1641,16 @@ Note:
1624
1641
 
1625
1642
  current_release = None
1626
1643
  for entry in commit_entries:
1627
- # Check if the entry contains a release tag
1644
+ # Check if the entry contains a release tag, it has a format like this:
1645
+ # 80cbe7a (HEAD -> main, tag: v2023.11.27.1, origin/main, origin/HEAD) Update readme
1628
1646
  match = re.search(release_pattern, entry)
1629
1647
  if match:
1630
1648
  current_release = match.group(1)
1631
1649
  if current_release not in release_commits:
1632
- release_commits[current_release] = []
1650
+ # remove the part between ()
1651
+ pattern = re.compile('\(.*?\) ')
1652
+ updated_entry = pattern.sub('', entry)
1653
+ release_commits[current_release] = [updated_entry]
1633
1654
  elif current_release:
1634
1655
  release_commits[current_release].append(entry)
1635
1656
  # Print the grouped commits to the console (you can write them to a file as needed)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tgwrap
3
- Version: 0.8.6
3
+ Version: 0.8.8
4
4
  Summary: A (terragrunt) wrapper around a (terraform) wrapper around ....
5
5
  Home-page: https://gitlab.com/lunadata/tgwrap
6
6
  License: MIT
@@ -2,10 +2,10 @@ tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  tgwrap/analyze.py,sha256=CsSaGv-be6ATy36z9X7x00gpKY59soJys2VbIzD-tmg,8726
3
3
  tgwrap/cli.py,sha256=weYPXnpZ1200L28tNGzVaO_GlX7wAdLn1nQZsHKpe3k,29060
4
4
  tgwrap/deploy.py,sha256=GBEtPTrKxvvSXJPi-peKmP6fjgY4z0PQ4gPSd9btleo,9560
5
- tgwrap/main.py,sha256=pPdbjJzThfNyGHOzXwLEKy-akKyMVkven4gnJq3B8wA,73120
5
+ tgwrap/main.py,sha256=rtsmZLB2pJC825HAi-AjER89GDRFgky52CkgYabHc0k,74195
6
6
  tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
7
- tgwrap-0.8.6.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
8
- tgwrap-0.8.6.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
9
- tgwrap-0.8.6.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
10
- tgwrap-0.8.6.dist-info/METADATA,sha256=m1FH55-TvQ3zZx1iAwjeLXScELq0slYwYCn1G_GfN80,11477
11
- tgwrap-0.8.6.dist-info/RECORD,,
7
+ tgwrap-0.8.8.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
8
+ tgwrap-0.8.8.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
9
+ tgwrap-0.8.8.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
10
+ tgwrap-0.8.8.dist-info/METADATA,sha256=syyDOrLBWEeUYnKoHS0qd5QDgl2n2Nn3GhRtMzmpdys,11477
11
+ tgwrap-0.8.8.dist-info/RECORD,,
File without changes