-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This removes a bit of if() condition wars in the BaseContainerImage and delegates it into its own class hierarchy, which allows to build a python container for appcol without having to do more subclasses.
- Loading branch information
1 parent
406b588
commit b11d643
Showing
8 changed files
with
97 additions
and
93 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
This file was deleted.
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
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
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,60 @@ | ||
"""Registry classes for container images.""" | ||
|
||
import dataclasses | ||
from abc import ABC | ||
from abc import abstractmethod | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class RegistryABC(ABC): | ||
"""Abstract Base Class for defining Registry specific content.""" | ||
|
||
_: dataclasses.KW_ONLY | ||
"""The base hostname for this registry instance""" | ||
registry: str | ||
"""The vendor that is put into the ``org.opencontainers.image.vendor`` label""" | ||
vendor: str | ||
|
||
@abstractmethod | ||
def url(self, container) -> str: | ||
pass | ||
|
||
|
||
class ApplicationCollectionRegistry(RegistryABC): | ||
"""Registry for the Rancher Application Collection Distribution Platform.""" | ||
|
||
def __init__(self): | ||
super().__init__(registry="dp.apps.rancher.io", vendor="SUSE LLC") | ||
|
||
def url(self, container) -> str: | ||
return f"https://apps.rancher.io/applications/{container.name}" | ||
|
||
|
||
class SUSERegistry(RegistryABC): | ||
"""Registry for the SUSE Registry.""" | ||
|
||
def __init__(self): | ||
super().__init__(registry="registry.suse.com", vendor="SUSE LLC") | ||
|
||
def url(self, container) -> str: | ||
if container.os_version.is_ltss: | ||
return "https://www.suse.com/products/long-term-service-pack-support/" | ||
return "https://www.suse.com/products/base-container-images/" | ||
|
||
|
||
class openSUSERegistry(RegistryABC): | ||
"""Registry for the openSUSE registry.""" | ||
|
||
def __init__(self): | ||
super().__init__(registry="registry.opensuse.org", vendor="openSUSE Project") | ||
|
||
def url(self, container) -> str: | ||
return "https://www.opensuse.org" | ||
|
||
|
||
def get_registry(container) -> RegistryABC: | ||
"""Return the appropriate registry for the container.""" | ||
if container.os_version.is_tumbleweed: | ||
return openSUSERegistry() | ||
return SUSERegistry() |
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