qontract-reconcile 0.10.1rc1129__py3-none-any.whl → 0.10.1rc1130__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.1rc1129
3
+ Version: 0.10.1rc1130
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
@@ -838,7 +838,7 @@ tools/app_interface_metrics_exporter.py,sha256=zkwkxdAUAxjdc-pzx2_oJXG25fo0Fnyd5
838
838
  tools/app_interface_reporter.py,sha256=oZPib4HPq0aZ2Zui1QGJGk6qQdfpeihujGDBnSdKyGE,17627
839
839
  tools/glitchtip_access_reporter.py,sha256=oPBnk_YoDuljU3v0FaChzOwwnk4vap1xEE67QEjzdqs,2948
840
840
  tools/glitchtip_access_revalidation.py,sha256=8kbBJk04mkq28kWoRDDkfCGIF3GRg3pJrFAh1sW0dbk,2821
841
- tools/qontract_cli.py,sha256=_OqTpZ57TGdWR_0Oc9sT83JVilLKbAz5NbPm1EyL34I,133385
841
+ tools/qontract_cli.py,sha256=sFwwL9GVUXnlxJV4glFKa1T4Q4IjNmgN0rex5aDIRyQ,135492
842
842
  tools/sd_app_sre_alert_report.py,sha256=e9vAdyenUz2f5c8-z-5WY0wv-SJ9aePKDH2r4IwB6pc,5063
843
843
  tools/template_validation.py,sha256=qpKYaTgk0GOPGa2Ct5_5sKdwIHtCAKIBGzsMPuJU5fw,3371
844
844
  tools/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -871,8 +871,8 @@ tools/test/test_qontract_cli.py,sha256=_D61RFGAN5x44CY1tYbouhlGXXABwYfxKSWSQx3Jr
871
871
  tools/test/test_saas_promotion_state.py,sha256=dy4kkSSAQ7bC0Xp2CociETGN-2aABEfL6FU5D9Jl00Y,6056
872
872
  tools/test/test_sd_app_sre_alert_report.py,sha256=v363r9zM7__0kR5K6mvJoGFcM9BvE33fWAayrqkpojA,2116
873
873
  tools/test/test_sre_checkpoints.py,sha256=SKqPPTl9ua0RFdSSofnoQX-JZE6dFLO3LRhfQzqtfh8,2607
874
- qontract_reconcile-0.10.1rc1129.dist-info/METADATA,sha256=Z1h9eqAPOgiPFSvnkYjuHeRDc1Xe5s3E1tX1VHVx1sc,2213
875
- qontract_reconcile-0.10.1rc1129.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
876
- qontract_reconcile-0.10.1rc1129.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
877
- qontract_reconcile-0.10.1rc1129.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
878
- qontract_reconcile-0.10.1rc1129.dist-info/RECORD,,
874
+ qontract_reconcile-0.10.1rc1130.dist-info/METADATA,sha256=S4CrU7hnXRPr8ACKCIDkMZMpEQMGPOqLx4p5CRGhV_8,2213
875
+ qontract_reconcile-0.10.1rc1130.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
876
+ qontract_reconcile-0.10.1rc1130.dist-info/entry_points.txt,sha256=GKQqCl2j2X1BJQ69een6rHcR26PmnxnONLNOQB-nRjY,491
877
+ qontract_reconcile-0.10.1rc1130.dist-info/top_level.txt,sha256=l5ISPoXzt0SdR4jVdkfa7RPSKNc8zAHYWAnR-Dw8Ey8,24
878
+ qontract_reconcile-0.10.1rc1130.dist-info/RECORD,,
tools/qontract_cli.py CHANGED
@@ -1371,6 +1371,57 @@ def aws_creds(ctx, account_name):
1371
1371
  print(f"export AWS_SECRET_ACCESS_KEY={secret['aws_secret_access_key']}")
1372
1372
 
1373
1373
 
1374
+ @root.command()
1375
+ @click.argument("account_name")
1376
+ @click.argument("bucket")
1377
+ @click.argument("src")
1378
+ @click.argument("dest")
1379
+ @click.argument("region", required=False, default="us-east-1")
1380
+ @click.pass_context
1381
+ def copy_tfstate(ctx, account_name, bucket, src, dest, region):
1382
+ """copy a manually managed terraform state file to the correct location expected by
1383
+ the terraform-repo integration.
1384
+
1385
+ SRC should include the full filename including the extension
1386
+
1387
+ DEST should include the filename without extension.
1388
+ """
1389
+ settings = queries.get_app_interface_settings()
1390
+ secret_reader = SecretReader(settings=settings)
1391
+ accounts = queries.get_aws_accounts(name=account_name, terraform_state=True)
1392
+ if not accounts:
1393
+ print(f"{account_name} not found.")
1394
+ sys.exit(1)
1395
+ account = accounts[0]
1396
+
1397
+ state_key = [
1398
+ i
1399
+ for i in account["terraformState"]["integrations"]
1400
+ if i["integration"] == "terraform-repo"
1401
+ ]
1402
+ if len(state_key) == 0:
1403
+ logging.error(
1404
+ "terraform-repo is missing a section in this account's '/dependencies/terraform-state-1.yml' file, please add one using the docs in https://gitlab.cee.redhat.com/service/app-interface/-/blob/master/docs/terraform-repo/sop/migrating-existing-state.md?ref_type=heads and then try again"
1405
+ )
1406
+ return
1407
+
1408
+ dest_key = f"{state_key[0]['key']}/{dest}-tf-repo.tfstate"
1409
+ dest_bucket = account["terraformState"]["bucket"]
1410
+
1411
+ with AWSApi(1, accounts, settings, secret_reader) as aws:
1412
+ prompt_text = f"Are you sure you want to copy 's3://{bucket}/{src}' to 's3://{dest_bucket}/{dest_key}'? This will overwrite any object currently at the destination path."
1413
+ if click.confirm(prompt_text):
1414
+ session = aws.get_session(account_name)
1415
+ s3_client = aws.get_session_client(session, "s3", region)
1416
+ copy_source = {
1417
+ "Bucket": bucket,
1418
+ "Key": src,
1419
+ }
1420
+
1421
+ s3_client.copy(copy_source, dest_bucket, dest_key)
1422
+ logging.info("successfully copied the statefile to the new location")
1423
+
1424
+
1374
1425
  @get.command(short_help='obtain "rosa create cluster" command by cluster name')
1375
1426
  @click.argument("cluster_name")
1376
1427
  @click.pass_context