-
Notifications
You must be signed in to change notification settings - Fork 23
oci: add OciCredentials model and harden credential resolution #654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,11 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
| from typing import Dict, Optional | ||
| from typing import TYPE_CHECKING, Dict, Optional | ||
|
|
||
| if TYPE_CHECKING: | ||
| from jumpstarter.common.oci import OciCredentials | ||
|
|
||
| import click | ||
| from jumpstarter_driver_composite.client import CompositeClient | ||
|
|
@@ -275,24 +280,19 @@ def _flash_operation(): | |
|
|
||
| return self._execute_flash_operation(_flash_operation, power_off=power_off) | ||
|
|
||
| def _read_oci_credentials(self, oci_url: str): | ||
| def _read_oci_credentials(self, oci_url: str) -> OciCredentials: | ||
| """Read OCI registry credentials from environment variables or auth files.""" | ||
| from jumpstarter.common.oci import resolve_oci_credentials | ||
|
|
||
| username, password = resolve_oci_credentials(oci_url) | ||
|
|
||
| if bool(username) != bool(password): | ||
| raise click.ClickException("OCI authentication requires both username and password") | ||
|
|
||
| return username, password | ||
| return resolve_oci_credentials(oci_url) | ||
|
|
||
| def _flash_oci_auto_impl( | ||
| self, | ||
| oci_url: str, | ||
| partitions: Dict[str, str] | None = None, | ||
| ): | ||
| """Core implementation of OCI flash without wrapper logic.""" | ||
| oci_username, oci_password = self._read_oci_credentials(oci_url) | ||
| creds = self._read_oci_credentials(oci_url) | ||
|
|
||
| self.logger.info("Checking for fastboot devices on Exporter...") | ||
| detection_result = self.call("detect_fastboot_device", 5, 2.0) | ||
|
|
@@ -307,8 +307,8 @@ def _flash_oci_auto_impl( | |
| "flash_oci_image", | ||
| oci_url, | ||
| partitions, | ||
| oci_username, | ||
| oci_password, | ||
| creds.username, | ||
| creds.plain_password, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [MEDIUM] Consider adding a test that mocks AI-generated, human reviewed |
||
| ) | ||
|
|
||
| # Display FLS output to user | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.