|
15 | 15 | import inquirer
|
16 | 16 | import requests
|
17 | 17 |
|
18 |
| -from .constants import HELM_BINARY_NAME, HELM_DOWNLOAD_URL_STUB, HELM_LATEST_URL |
| 18 | +from .constants import ( |
| 19 | + HELM_BINARY_NAME, |
| 20 | + HELM_BLESSED_NAME_AND_CHECKSUMS, |
| 21 | + HELM_BLESSED_VERSION, |
| 22 | + HELM_DOWNLOAD_URL_STUB, |
| 23 | + HELM_LATEST_URL, |
| 24 | +) |
19 | 25 | from .graph import inquirer_create_network
|
20 | 26 | from .network import copy_network_defaults, copy_scenario_defaults
|
21 | 27 |
|
@@ -431,6 +437,17 @@ def get_latest_version_of_helm() -> Optional[str]:
|
431 | 437 | return None
|
432 | 438 |
|
433 | 439 |
|
| 440 | +def write_blessed_checksum(helm_filename: str, dest_path: str): |
| 441 | + checksum = next( |
| 442 | + (b["checksum"] for b in HELM_BLESSED_NAME_AND_CHECKSUMS if b["name"] == helm_filename), None |
| 443 | + ) |
| 444 | + if checksum: |
| 445 | + with open(dest_path, "w") as f: |
| 446 | + f.write(checksum) |
| 447 | + else: |
| 448 | + click.secho("Could not find a matching helm binary and checksum", fg="red") |
| 449 | + |
| 450 | + |
434 | 451 | def verify_checksum(file_path, checksum_path):
|
435 | 452 | click.secho(" Verifying checksum...", fg="blue")
|
436 | 453 | sha256_hash = hashlib.sha256()
|
@@ -462,13 +479,7 @@ def install_helm_rootlessly_to_venv():
|
462 | 479 | )
|
463 | 480 | sys.exit(1)
|
464 | 481 |
|
465 |
| - version = get_latest_version_of_helm() |
466 |
| - if version is None: |
467 |
| - click.secho( |
468 |
| - "Error: Could not fetch the latest version of Helm. Please check your internet connection.", |
469 |
| - fg="yellow", |
470 |
| - ) |
471 |
| - sys.exit(1) |
| 482 | + version = HELM_BLESSED_VERSION |
472 | 483 |
|
473 | 484 | os_name = get_os_name_for_helm()
|
474 | 485 | if os_name is None:
|
@@ -497,15 +508,14 @@ def install_helm_rootlessly_to_venv():
|
497 | 508 |
|
498 | 509 | helm_filename = f"{HELM_BINARY_NAME}-{version}-{os_name}-{arch}.tar.gz"
|
499 | 510 | helm_url = f"{HELM_DOWNLOAD_URL_STUB}{helm_filename}"
|
500 |
| - checksum_url = f"{helm_url}.sha256" |
501 | 511 |
|
502 | 512 | try:
|
503 | 513 | with tempfile.TemporaryDirectory() as temp_dir:
|
504 | 514 | helm_archive_path = os.path.join(temp_dir, helm_filename)
|
505 | 515 | checksum_path = os.path.join(temp_dir, f"{helm_filename}.sha256")
|
506 | 516 |
|
507 | 517 | download_file(helm_url, helm_archive_path)
|
508 |
| - download_file(checksum_url, checksum_path) |
| 518 | + write_blessed_checksum(helm_filename, checksum_path) |
509 | 519 | verify_checksum(helm_archive_path, checksum_path)
|
510 | 520 |
|
511 | 521 | # Extract Helm and install it in the virtual environment's bin folder
|
|
0 commit comments