tgwrap 0.7.16__py3-none-any.whl → 0.7.18__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 +6 -1
- tgwrap/main.py +42 -16
- {tgwrap-0.7.16.dist-info → tgwrap-0.7.18.dist-info}/METADATA +1 -1
- tgwrap-0.7.18.dist-info/RECORD +10 -0
- tgwrap-0.7.16.dist-info/RECORD +0 -10
- {tgwrap-0.7.16.dist-info → tgwrap-0.7.18.dist-info}/LICENSE +0 -0
- {tgwrap-0.7.16.dist-info → tgwrap-0.7.18.dist-info}/WHEEL +0 -0
- {tgwrap-0.7.16.dist-info → tgwrap-0.7.18.dist-info}/entry_points.txt +0 -0
tgwrap/cli.py
CHANGED
@@ -774,8 +774,12 @@ def clean(verbose, working_dir):
|
|
774
774
|
@click.option('--working-dir', '-w', default=None,
|
775
775
|
help='Working directory, when omitted the current directory is used',
|
776
776
|
)
|
777
|
+
@click.option('--include-nbr-of-releases', '-i',
|
778
|
+
type=int, default=20, show_default=True,
|
779
|
+
help='Max number of releases to include',
|
780
|
+
)
|
777
781
|
@click.version_option(version=__version__)
|
778
|
-
def change_log(changelog_file, verbose, working_dir):
|
782
|
+
def change_log(changelog_file, verbose, working_dir, include_nbr_of_releases):
|
779
783
|
""" Experimental! Generate a change log """
|
780
784
|
|
781
785
|
check_latest_version(verbose)
|
@@ -784,6 +788,7 @@ def change_log(changelog_file, verbose, working_dir):
|
|
784
788
|
tgwrap.change_log(
|
785
789
|
changelog_file=changelog_file,
|
786
790
|
working_dir=working_dir,
|
791
|
+
include_nbr_of_releases=include_nbr_of_releases,
|
787
792
|
)
|
788
793
|
|
789
794
|
# this is needed for the vscode debugger to work
|
tgwrap/main.py
CHANGED
@@ -110,7 +110,7 @@ class TgWrap():
|
|
110
110
|
}
|
111
111
|
|
112
112
|
lock_stmt = ''
|
113
|
-
if no_lock and command in ['init', 'validate', 'validate-inputs', 'plan', 'info', 'output', 'show']:
|
113
|
+
if no_lock and command in ['init', 'validate', 'validate-inputs', 'plan', 'info', 'output', 'show', 'state']:
|
114
114
|
lock_stmt = '-lock=false'
|
115
115
|
self.printer.warning('Terraform state will NOT be locked')
|
116
116
|
elif no_lock:
|
@@ -958,6 +958,9 @@ class TgWrap():
|
|
958
958
|
include_dirs, exclude_dirs, planfile_dir, terragrunt_args):
|
959
959
|
""" Analyzes the plan files """
|
960
960
|
|
961
|
+
def calculate_score(major: int, medium: int, minor: int) -> float :
|
962
|
+
return major * 10 + medium + minor / 10
|
963
|
+
|
961
964
|
self.printer.verbose("Attempting to 'analyze'")
|
962
965
|
if terragrunt_args:
|
963
966
|
self.printer.verbose(f"- with additional parameters: {' '.join(terragrunt_args)}")
|
@@ -1080,14 +1083,25 @@ class TgWrap():
|
|
1080
1083
|
"major": 0,
|
1081
1084
|
"unknown": 0,
|
1082
1085
|
"total": 0,
|
1086
|
+
"score": 0,
|
1083
1087
|
}
|
1084
1088
|
|
1085
1089
|
for key, value in changes.items():
|
1086
1090
|
for type in ["minor", "medium", "major", "unknown", "total"]:
|
1087
1091
|
total_drifts[type] += value["drifts"][type]
|
1092
|
+
|
1093
|
+
# the formula below is just a way to achieve a numeric results that is coming from the various drift categories
|
1094
|
+
value['drifts']['score'] = calculate_score(
|
1095
|
+
major = value['drifts']['major'],
|
1096
|
+
medium = value['drifts']['medium'],
|
1097
|
+
minor = value['drifts']['minor'],
|
1098
|
+
)
|
1099
|
+
value['drifts']['score'] = value['drifts']['major'] * 10 + value['drifts']['medium'] + value['drifts']['minor'] / 10
|
1088
1100
|
|
1089
1101
|
# the formula below is just a way to achieve a numeric results that is coming from the various drift categories
|
1090
1102
|
total_drift_score = total_drifts['major'] * 10 + total_drifts['medium'] + total_drifts['minor'] / 10
|
1103
|
+
total_drifts['score'] = total_drift_score
|
1104
|
+
|
1091
1105
|
self.printer.header(f"Drift score: {total_drift_score} ({total_drifts['major']}.{total_drifts['medium']}.{total_drifts['minor']})")
|
1092
1106
|
if total_drifts["unknown"] > 0:
|
1093
1107
|
self.printer.warning(f"For {total_drifts['unknown']} resources, drift score is not configured, please update configuration!")
|
@@ -1096,15 +1110,22 @@ class TgWrap():
|
|
1096
1110
|
for m in value["unknowns"]:
|
1097
1111
|
self.printer.warning(f' -> {m}')
|
1098
1112
|
|
1113
|
+
|
1114
|
+
|
1099
1115
|
if out:
|
1100
1116
|
# in the output we convert the dict of dicts to a list of dicts as it makes processing
|
1101
1117
|
# (e.g. by telegraph) easier.
|
1102
|
-
|
1118
|
+
output = {
|
1119
|
+
"changes": [],
|
1120
|
+
"summary": {},
|
1121
|
+
}
|
1103
1122
|
for key, value in changes.items():
|
1104
1123
|
value['module'] = key
|
1105
|
-
|
1124
|
+
output["changes"].append(value)
|
1106
1125
|
|
1107
|
-
|
1126
|
+
output["summary"] = total_drifts
|
1127
|
+
|
1128
|
+
print(json.dumps(output, indent=4))
|
1108
1129
|
|
1109
1130
|
if not ts_validation_successful:
|
1110
1131
|
self.printer.error("Analysis detected unauthorised deletions, please check your configuration!!!")
|
@@ -1626,7 +1647,7 @@ Note:
|
|
1626
1647
|
self.printer.verbose(rc)
|
1627
1648
|
self.printer.normal("Cleaned the temporary files")
|
1628
1649
|
|
1629
|
-
def change_log(self, changelog_file, working_dir):
|
1650
|
+
def change_log(self, changelog_file, working_dir, include_nbr_of_releases):
|
1630
1651
|
""" Generate a change log """
|
1631
1652
|
|
1632
1653
|
# Run 'git log' to capture the Git log as a string
|
@@ -1637,8 +1658,13 @@ Note:
|
|
1637
1658
|
cwd=working_dir if working_dir else None,
|
1638
1659
|
)
|
1639
1660
|
|
1640
|
-
# Define a regular expression pattern to extract release tags
|
1641
|
-
|
1661
|
+
# Define a regular expression pattern to extract release tags
|
1662
|
+
# The following formats are supported:
|
1663
|
+
# vYYYY.MM.DD
|
1664
|
+
# vYYYYMMDD
|
1665
|
+
# vYYYY.MM.DD.01
|
1666
|
+
# vYYYYMMDD.01
|
1667
|
+
release_pattern = r'\b(v\d{4}\.?\d{1,2}\.?\d{1,2}(\.\d+)?)\b'
|
1642
1668
|
|
1643
1669
|
# Split the Git log into individual commit entries
|
1644
1670
|
release_commits = {}
|
@@ -1654,18 +1680,18 @@ Note:
|
|
1654
1680
|
release_commits[current_release] = []
|
1655
1681
|
elif current_release:
|
1656
1682
|
release_commits[current_release].append(entry)
|
1657
|
-
|
1658
1683
|
# Print the grouped commits to the console (you can write them to a file as needed)
|
1659
1684
|
changelog = ""
|
1685
|
+
counter = 0
|
1660
1686
|
for release, commits in release_commits.items():
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1687
|
+
if len(commits) > 0:
|
1688
|
+
counter += 1
|
1689
|
+
|
1690
|
+
changelog = changelog + f"\nRelease: {release}\n - "
|
1691
|
+
changelog = changelog + '\n - '.join(commits) + '\n'
|
1692
|
+
|
1693
|
+
if include_nbr_of_releases and counter > include_nbr_of_releases:
|
1694
|
+
break
|
1669
1695
|
|
1670
1696
|
# do we need to update an existingchange log file?
|
1671
1697
|
if changelog_file:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
tgwrap/analyze.py,sha256=DTNQ10yI1pmKr6TuMJOQFjIWetu589GZ2bBlL8hz37Q,8576
|
3
|
+
tgwrap/cli.py,sha256=cvGWGCyY78TasT4RajJyHUKUihmRxd_TBb_VyepgOLE,27858
|
4
|
+
tgwrap/main.py,sha256=GBtz-Lii_sPVDedzjXRaVe6TBB6-k8mB0iOH_uXNJcY,77443
|
5
|
+
tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
|
6
|
+
tgwrap-0.7.18.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
|
7
|
+
tgwrap-0.7.18.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
8
|
+
tgwrap-0.7.18.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
|
9
|
+
tgwrap-0.7.18.dist-info/METADATA,sha256=MO8Z3V8tTJi1PHJYnpT4TxQ_DGIqZbQJPfOXJ2lqSVI,10610
|
10
|
+
tgwrap-0.7.18.dist-info/RECORD,,
|
tgwrap-0.7.16.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
tgwrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
tgwrap/analyze.py,sha256=DTNQ10yI1pmKr6TuMJOQFjIWetu589GZ2bBlL8hz37Q,8576
|
3
|
-
tgwrap/cli.py,sha256=6zJRQ7PKE-Vkzz173sNCaPKmqzYOHfUBSgLOPs4zK74,27630
|
4
|
-
tgwrap/main.py,sha256=WXfxMv1XzOi_aVBdFbW9zYX1WGIIh2bKmgrEdel4Q44,76538
|
5
|
-
tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
|
6
|
-
tgwrap-0.7.16.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
|
7
|
-
tgwrap-0.7.16.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
|
8
|
-
tgwrap-0.7.16.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
|
9
|
-
tgwrap-0.7.16.dist-info/METADATA,sha256=RCLLigdmLL0avYMDXPpmUt3tVnhzgvJp7F9EYEo5iiQ,10610
|
10
|
-
tgwrap-0.7.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|