tgwrap 0.7.17__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/main.py CHANGED
@@ -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
- changes_for_output = []
1118
+ output = {
1119
+ "changes": [],
1120
+ "summary": {},
1121
+ }
1103
1122
  for key, value in changes.items():
1104
1123
  value['module'] = key
1105
- changes_for_output.append(value)
1124
+ output["changes"].append(value)
1125
+
1126
+ output["summary"] = total_drifts
1106
1127
 
1107
- print(json.dumps(changes_for_output, indent=4))
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!!!")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tgwrap
3
- Version: 0.7.17
3
+ Version: 0.7.18
4
4
  Summary: A (terragrunt) wrapper around a (terraform) wrapper around ....
5
5
  Home-page: https://gitlab.com/lunadata/tgwrap
6
6
  License: MIT
@@ -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,,
@@ -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=cvGWGCyY78TasT4RajJyHUKUihmRxd_TBb_VyepgOLE,27858
4
- tgwrap/main.py,sha256=4em6FkwwTefFQzRLesHgRPQsZlW-UiW6WIb9JvzaAjE,76653
5
- tgwrap/printer.py,sha256=dkcOCPIPB-IP6pn8QMpa06xlcqPFVaDvxnz-QEpDJV0,2663
6
- tgwrap-0.7.17.dist-info/LICENSE,sha256=VT-AVxIXt3EQTC-7Hy1uPGnrDNJLqfcgLgJD78fiyx4,1065
7
- tgwrap-0.7.17.dist-info/WHEEL,sha256=vVCvjcmxuUltf8cYhJ0sJMRDLr1XsPuxEId8YDzbyCY,88
8
- tgwrap-0.7.17.dist-info/entry_points.txt,sha256=H8X0PMPmd4aW7Y9iyChZ0Ug6RWGXqhRUvHH-6f6Mxz0,42
9
- tgwrap-0.7.17.dist-info/METADATA,sha256=XalNmLZuPVSi-1KxRNUju_dxvIShyGV1wOve_7sXp_U,10610
10
- tgwrap-0.7.17.dist-info/RECORD,,