-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
21,008 additions
and
330 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
"""Interactive harness for Google Artifact Registry.""" | ||
|
||
from rsp_reaper.config import KeepPolicy, RegistryConfig | ||
from rsp_reaper.storage.gar import GARClient | ||
|
||
c = GARClient( | ||
location="us-central1", | ||
project_id="rubin-shared-services-71ec", | ||
repository="sciplat", | ||
image="sciplat-lab", | ||
cfg = RegistryConfig( | ||
category="pkg.dev", | ||
registry="https://us-central1-docker.pkg.dev", | ||
owner="rubin-shared-services-71ec", | ||
namespace="sciplat", | ||
repository="sciplat-lab", | ||
keep = KeepPolicy(), | ||
dry_run=True, | ||
debug=True, | ||
) | ||
c = GARClient(cfg=cfg) | ||
# No authentication; set up application default credentials in the environment | ||
c.scan_repo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"""Interactive harness for Google Artifact Registry.""" | ||
from pathlib import Path | ||
from rsp_reaper.config import KeepPolicy, RegistryConfig | ||
from rsp_reaper.models.image import ImageVersionClass | ||
from rsp_reaper.storage.gar import GARClient | ||
|
||
input_file = ( Path(__file__).parent.parent.parent / "tests" / "support" / | ||
"gar.contents.json") | ||
|
||
cfg = RegistryConfig( | ||
category="pkg.dev", | ||
registry="https://us-central1-docker.pkg.dev", | ||
owner="rubin-shared-services-71ec", | ||
namespace="sciplat", | ||
repository="sciplat-lab", | ||
dry_run=True, | ||
debug=True, | ||
input_file=input_file, | ||
keep = KeepPolicy() | ||
) | ||
|
||
c = GARClient(cfg=cfg) | ||
c.categorize(ImageVersionClass.RSP) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,98 @@ | ||
"""Configuration for a reaper for a particular container registry.""" | ||
|
||
from dataclasses import dataclass | ||
|
||
from .models.registry_category import RegistryCategory | ||
from dataclasses import dataclass, field | ||
from pathlib import Path | ||
|
||
|
||
@dataclass | ||
class RegistryAuth: | ||
"""Generic authentication item for a container registry.""" | ||
|
||
realm: str | ||
username: str | ||
password: str | ||
realm: str|None = None | ||
username: str|None = None | ||
password: str|None = None | ||
|
||
|
||
class LatestSemverKeepers: | ||
"""Number of items to keep for latest major semver release. Default is | ||
"do not purge". | ||
""" | ||
|
||
minor: int | None = None | ||
patch: int | None = None | ||
build: int | None = None | ||
|
||
|
||
class OlderSemverKeepers: | ||
"""Number of items to keep for previous major semver releases. Default is | ||
"do not purge". | ||
""" | ||
|
||
major: int | None = None | ||
minor: int | None = None | ||
patch: int | None = None | ||
build: int | None = None | ||
|
||
|
||
@dataclass | ||
class SemverKeepers: | ||
"""Within each of latest_major and older, how many minor versions, | ||
how many patch versions within each of those, and how many builds of each | ||
of those, to keep. Older also has a major version number. For instance, | ||
older.major might be 3, and then when version 5.0 came out, you would | ||
keep some images for the 2.x.y, 3.x.y, and 4.x.y series, but no 1.x images. | ||
""" | ||
|
||
latest_major: LatestSemverKeepers = field( | ||
default_factory=LatestSemverKeepers | ||
) | ||
older: OlderSemverKeepers = field(default_factory=OlderSemverKeepers) | ||
|
||
|
||
@dataclass | ||
class RSPKeepers: | ||
"""Aliases are never purged. Default for everything else is "do not | ||
purge". | ||
""" | ||
|
||
release: int | None = None | ||
weekly: int | None = None | ||
daily: int | None = None | ||
release_candidate: int | None = None | ||
experimental: int | None = None | ||
unknown: int | None = None | ||
|
||
|
||
@dataclass | ||
class KeepPolicy: | ||
"""How many of each image category to keep. `-1` or `None` means | ||
"don't reap that category at all". `0` means "purge them all". | ||
The default is to purge nothing. | ||
""" | ||
|
||
untagged: int | None = None | ||
semver: SemverKeepers | None = field(default_factory=SemverKeepers) | ||
rsp: RSPKeepers | None = field(default_factory=RSPKeepers) | ||
|
||
|
||
@dataclass | ||
class ContainerRegistryConfig: | ||
"""Configuration for a particular container registry.""" | ||
|
||
namespace: str | ||
repository: str | ||
registry: str | ||
category: RegistryCategory | ||
project: str | None = None | ||
class RegistryConfig: | ||
"""Configuration to talk to a particular container registry.""" | ||
|
||
registry: str # URL of registry host | ||
owner: str # Usually repo owner; at GAR, project ID | ||
repository: str # Repository name, e.g. "sciplat-lab" | ||
category: str | ||
keep: KeepPolicy | ||
namespace: str | None = None # Intermediate layer if any; GAR: "sciplat" | ||
auth: RegistryAuth | None = None | ||
dry_run: bool = True | ||
debug: bool = True | ||
input_file: Path | None = None | ||
|
||
|
||
@dataclass | ||
class Config: | ||
"""Configuration for multiple registries.""" | ||
|
||
registries: list[RegistryConfig] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.