Skip to content

Commit d3c2e99

Browse files
feat: Container Registry (#194)
* Add pull command. Refactor docker cli mechs. * co-pilot suggestions * fix: fixed platform status checker * Typing fix --------- Co-authored-by: Brian Greunke <[email protected]>
1 parent 2166563 commit d3c2e99

33 files changed

+1800
-1578
lines changed

docs/sdk/api.mdx

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -505,37 +505,6 @@ def export_timeseries(
505505
```
506506

507507

508-
</Accordion>
509-
510-
### get\_container\_registry\_credentials
511-
512-
```python
513-
get_container_registry_credentials() -> (
514-
ContainerRegistryCredentials
515-
)
516-
```
517-
518-
Retrieves container registry credentials for Docker image access.
519-
520-
**Returns:**
521-
522-
* `ContainerRegistryCredentials`
523-
–The container registry credentials object.
524-
525-
<Accordion title="Source code in dreadnode/api/client.py" icon="code">
526-
```python
527-
def get_container_registry_credentials(self) -> ContainerRegistryCredentials:
528-
"""
529-
Retrieves container registry credentials for Docker image access.
530-
531-
Returns:
532-
The container registry credentials object.
533-
"""
534-
response = self.request("POST", "/platform/registry-token")
535-
return ContainerRegistryCredentials(**response.json())
536-
```
537-
538-
539508
</Accordion>
540509

541510
### get\_device\_codes
@@ -577,13 +546,44 @@ def get_github_access_token(self, repos: list[str]) -> GithubTokenResponse:
577546
```
578547

579548

549+
</Accordion>
550+
551+
### get\_platform\_registry\_credentials
552+
553+
```python
554+
get_platform_registry_credentials() -> (
555+
ContainerRegistryCredentials
556+
)
557+
```
558+
559+
Retrieves container registry credentials for Docker image access.
560+
561+
**Returns:**
562+
563+
* `ContainerRegistryCredentials`
564+
–The container registry credentials object.
565+
566+
<Accordion title="Source code in dreadnode/api/client.py" icon="code">
567+
```python
568+
def get_platform_registry_credentials(self) -> ContainerRegistryCredentials:
569+
"""
570+
Retrieves container registry credentials for Docker image access.
571+
572+
Returns:
573+
The container registry credentials object.
574+
"""
575+
response = self.request("POST", "/platform/registry-token")
576+
return ContainerRegistryCredentials(**response.json())
577+
```
578+
579+
580580
</Accordion>
581581

582582
### get\_platform\_releases
583583

584584
```python
585585
get_platform_releases(
586-
tag: str, services: list[str], cli_version: str | None
586+
tag: str, services: list[str]
587587
) -> RegistryImageDetails
588588
```
589589

@@ -596,35 +596,17 @@ Resolves the platform releases for the current project.
596596

597597
<Accordion title="Source code in dreadnode/api/client.py" icon="code">
598598
```python
599-
def get_platform_releases(
600-
self, tag: str, services: list[str], cli_version: str | None
601-
) -> RegistryImageDetails:
599+
def get_platform_releases(self, tag: str, services: list[str]) -> RegistryImageDetails:
602600
"""
603601
Resolves the platform releases for the current project.
604602
605603
Returns:
606604
The resolved platform releases as a ResolveReleasesResponse object.
607605
"""
608-
payload = {
609-
"tag": tag,
610-
"services": services,
611-
"cli_version": cli_version,
612-
}
613-
try:
614-
response = self.request("POST", "/platform/get-releases", json_data=payload)
615-
616-
except RuntimeError as e:
617-
if "403" in str(e):
618-
raise RuntimeError("You do not have access to platform releases.") from e
619-
620-
if "404" in str(e):
621-
if "Image not found" in str(e):
622-
raise RuntimeError("Image not found") from e
606+
from dreadnode.version import VERSION
623607

624-
raise RuntimeError(
625-
f"Failed to get platform releases: {e}. The feature is likely disabled on this server"
626-
) from e
627-
raise
608+
payload = {"tag": tag, "services": services, "cli_version": VERSION}
609+
response = self.request("POST", "/platform/get-releases", json_data=payload)
628610
return RegistryImageDetails(**response.json())
629611
```
630612

docs/sdk/main.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ def configure(
329329
# Log config information for clarity
330330
if self.server or self.token or self.local_dir:
331331
destination = self.server or DEFAULT_SERVER_URL or "local storage"
332-
rich.print(f"Dreadnode logging to [orange_red1]{destination}[/] ({config_source})")
332+
logging_console.print(
333+
f"Dreadnode logging to [orange_red1]{destination}[/] ({config_source})"
334+
)
333335

334336
# Warn the user if the profile didn't resolve
335337
elif active_profile and not (self.server or self.token):
336-
rich.print(
338+
logging_console.print(
337339
f":exclamation: Dreadnode profile [orange_red1]{active_profile}[/] appears invalid."
338340
)
339341

dreadnode/api/client.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ def get_user_data_credentials(self) -> UserDataCredentials:
726726

727727
# Container registry access
728728

729-
def get_container_registry_credentials(self) -> ContainerRegistryCredentials:
729+
def get_platform_registry_credentials(self) -> ContainerRegistryCredentials:
730730
"""
731731
Retrieves container registry credentials for Docker image access.
732732
@@ -736,35 +736,17 @@ def get_container_registry_credentials(self) -> ContainerRegistryCredentials:
736736
response = self.request("POST", "/platform/registry-token")
737737
return ContainerRegistryCredentials(**response.json())
738738

739-
def get_platform_releases(
740-
self, tag: str, services: list[str], cli_version: str | None
741-
) -> RegistryImageDetails:
739+
def get_platform_releases(self, tag: str, services: list[str]) -> RegistryImageDetails:
742740
"""
743741
Resolves the platform releases for the current project.
744742
745743
Returns:
746744
The resolved platform releases as a ResolveReleasesResponse object.
747745
"""
748-
payload = {
749-
"tag": tag,
750-
"services": services,
751-
"cli_version": cli_version,
752-
}
753-
try:
754-
response = self.request("POST", "/platform/get-releases", json_data=payload)
755-
756-
except RuntimeError as e:
757-
if "403" in str(e):
758-
raise RuntimeError("You do not have access to platform releases.") from e
759-
760-
if "404" in str(e):
761-
if "Image not found" in str(e):
762-
raise RuntimeError("Image not found") from e
746+
from dreadnode.version import VERSION
763747

764-
raise RuntimeError(
765-
f"Failed to get platform releases: {e}. The feature is likely disabled on this server"
766-
) from e
767-
raise
748+
payload = {"tag": tag, "services": services, "cli_version": VERSION}
749+
response = self.request("POST", "/platform/get-releases", json_data=payload)
768750
return RegistryImageDetails(**response.json())
769751

770752
def get_platform_templates(self, tag: str) -> bytes:

0 commit comments

Comments
 (0)