qontract-reconcile 0.10.1rc599__py3-none-any.whl → 0.10.1rc601__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-reconcile
3
- Version: 0.10.1rc599
3
+ Version: 0.10.1rc601
4
4
  Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
5
5
  Home-page: https://github.com/app-sre/qontract-reconcile
6
6
  Author: Red Hat App-SRE Team
@@ -693,7 +693,7 @@ tools/app_interface_metrics_exporter.py,sha256=zkwkxdAUAxjdc-pzx2_oJXG25fo0Fnyd5
693
693
  tools/app_interface_reporter.py,sha256=upA-J-n-HXHKVDINRuMR7vTt-iJvQORKUVi9D3leQto,17738
694
694
  tools/glitchtip_access_reporter.py,sha256=oPBnk_YoDuljU3v0FaChzOwwnk4vap1xEE67QEjzdqs,2948
695
695
  tools/glitchtip_access_revalidation.py,sha256=8kbBJk04mkq28kWoRDDkfCGIF3GRg3pJrFAh1sW0dbk,2821
696
- tools/qontract_cli.py,sha256=X6F63x-1m7iuPvnrxRqkav3ZUaU-tC4fmaouhVGy1TQ,107850
696
+ tools/qontract_cli.py,sha256=cnZLJJS-FRUQFUAD90ivt-WEv8NfaemqBvZ9CaFV_kI,110957
697
697
  tools/sd_app_sre_alert_report.py,sha256=e9vAdyenUz2f5c8-z-5WY0wv-SJ9aePKDH2r4IwB6pc,5063
698
698
  tools/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
699
699
  tools/cli_commands/gpg_encrypt.py,sha256=w8hl4jIEWk5wKbEFN6fVEOwUJGmdlvOqYodW3XSN7mU,4978
@@ -704,8 +704,8 @@ tools/test/test_app_interface_metrics_exporter.py,sha256=SX7qL3D1SIRKFo95FoQztvf
704
704
  tools/test/test_qontract_cli.py,sha256=OvalpVRfY4pNmpMaWHHYqBjV68b1eGQjX8SCyTAXb1w,3501
705
705
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
706
706
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
707
- qontract_reconcile-0.10.1rc599.dist-info/METADATA,sha256=U5RxYIJZLus6WO-n0-8I8MVyBmIG3Xg12gshZfrVMd8,2349
708
- qontract_reconcile-0.10.1rc599.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
709
- qontract_reconcile-0.10.1rc599.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
710
- qontract_reconcile-0.10.1rc599.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
711
- qontract_reconcile-0.10.1rc599.dist-info/RECORD,,
707
+ qontract_reconcile-0.10.1rc601.dist-info/METADATA,sha256=xTaPAHRbNj68qwYjL7rWiII4D89lyuJWpmOg4fiBP_g,2349
708
+ qontract_reconcile-0.10.1rc601.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
709
+ qontract_reconcile-0.10.1rc601.dist-info/entry_points.txt,sha256=rTjAv28I_CHLM8ID3OPqMI_suoQ9s7tFbim4aYjn9kk,376
710
+ qontract_reconcile-0.10.1rc601.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
711
+ qontract_reconcile-0.10.1rc601.dist-info/RECORD,,
tools/qontract_cli.py CHANGED
@@ -90,6 +90,7 @@ from reconcile.utils.early_exit_cache import (
90
90
  EarlyExitCache,
91
91
  )
92
92
  from reconcile.utils.environ import environ
93
+ from reconcile.utils.external_resource_spec import ExternalResourceSpec
93
94
  from reconcile.utils.external_resources import (
94
95
  PROVIDER_AWS,
95
96
  get_external_resource_specs,
@@ -1492,6 +1493,103 @@ def aws_terraform_resources(ctx):
1492
1493
  print_output(ctx.obj["options"], results.values(), columns)
1493
1494
 
1494
1495
 
1496
+ def rds_attr(
1497
+ attr: str, overrides: dict[str, str], defaults: dict[str, str]
1498
+ ) -> str | None:
1499
+ return overrides.get(attr) or defaults.get(attr)
1500
+
1501
+
1502
+ def region_from_az(az: str | None) -> str | None:
1503
+ if not az:
1504
+ return None
1505
+ return az[:-1]
1506
+
1507
+
1508
+ def rds_region(
1509
+ spec: ExternalResourceSpec,
1510
+ overrides: dict[str, str],
1511
+ defaults: dict[str, str],
1512
+ accounts: dict[str, Any],
1513
+ ) -> str | None:
1514
+ return (
1515
+ spec.resource.get("region")
1516
+ or rds_attr("region", overrides, defaults)
1517
+ or region_from_az(spec.resource.get("availability_zone"))
1518
+ or region_from_az(rds_attr("availability_zone", overrides, defaults))
1519
+ or accounts[spec.provisioner_name].get("resourcesDefaultRegion")
1520
+ )
1521
+
1522
+
1523
+ @get.command
1524
+ @click.pass_context
1525
+ def rds(ctx):
1526
+ namespaces = tfr.get_namespaces()
1527
+ accounts = {a["name"]: a for a in queries.get_aws_accounts()}
1528
+ results = []
1529
+ for namespace in namespaces:
1530
+ specs = [
1531
+ s
1532
+ for s in get_external_resource_specs(
1533
+ namespace.dict(by_alias=True), provision_provider=PROVIDER_AWS
1534
+ )
1535
+ if s.provider == "rds"
1536
+ ]
1537
+ for spec in specs:
1538
+ defaults = yaml.safe_load(
1539
+ gql.get_resource(spec.resource["defaults"])["content"]
1540
+ )
1541
+ overrides = json.loads(spec.resource.get("overrides") or "{}")
1542
+ item = {
1543
+ "identifier": spec.identifier,
1544
+ "account": spec.provisioner_name,
1545
+ "account_uid": accounts[spec.provisioner_name]["uid"],
1546
+ "region": rds_region(spec, overrides, defaults, accounts),
1547
+ "engine": rds_attr("engine", overrides, defaults),
1548
+ "engine_version": rds_attr("engine_version", overrides, defaults),
1549
+ "instance_class": rds_attr("instance_class", overrides, defaults),
1550
+ }
1551
+ results.append(item)
1552
+
1553
+ if ctx.obj["options"]["output"] == "md":
1554
+ json_table = {
1555
+ "filter": True,
1556
+ "fields": [
1557
+ {"key": "identifier", "sortable": True},
1558
+ {"key": "account", "sortable": True},
1559
+ {"key": "account_uid", "sortable": True},
1560
+ {"key": "region", "sortable": True},
1561
+ {"key": "engine", "sortable": True},
1562
+ {"key": "engine_version", "sortable": True},
1563
+ {"key": "instance_class", "sortable": True},
1564
+ ],
1565
+ "items": results,
1566
+ }
1567
+
1568
+ print(
1569
+ f"""
1570
+ You can view the source of this Markdown to extract the JSON data.
1571
+
1572
+ {len(results)} RDS instances found.
1573
+
1574
+ ```json:table
1575
+ {json.dumps(json_table)}
1576
+ ```
1577
+ """
1578
+ )
1579
+ else:
1580
+ columns = [
1581
+ "identifier",
1582
+ "account",
1583
+ "account_uid",
1584
+ "region",
1585
+ "engine",
1586
+ "engine_version",
1587
+ "instance_class",
1588
+ ]
1589
+ ctx.obj["options"]["sort"] = False
1590
+ print_output(ctx.obj["options"], results, columns)
1591
+
1592
+
1495
1593
  @get.command()
1496
1594
  @click.pass_context
1497
1595
  def products(ctx):