Skip to content

Commit

Permalink
Convert pretty_reference into a abstract property
Browse files Browse the repository at this point in the history
This allows us to provide a better references depending on the container type
  • Loading branch information
dcermak committed May 15, 2024
1 parent 1584aac commit 0797736
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/bci_build/package/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,9 +982,14 @@ def reference(self) -> str:
pass

@property
@abc.abstractmethod
def pretty_reference(self) -> str:
"""
Returns the human readable pretty URL to this image. Used in image documentation.
"""Returns the human readable registry URL to this image. It is intended
to be used in the image documentation.
This url needn't point to an exact version-release but can include just
the major os version or the latest tag.
"""
return (
f"{self.registry}/{self._registry_prefix}/{self.name}:{self.version_label}"
Expand Down Expand Up @@ -1361,6 +1366,12 @@ def reference(self) -> str:
+ f":{self.version_label}-{self._release_suffix}"
)

@property
def pretty_reference(self) -> str:
return f"{self.registry}/{self._registry_prefix}/{self.name}:" + (
"latest" if self.is_latest else self.version_label
)

@property
def build_version(self) -> str | None:
build_ver = super().build_version
Expand Down Expand Up @@ -1441,6 +1452,10 @@ def build_tags(self) -> list[str]:
def reference(self) -> str:
return f"{self.registry}/{self._registry_prefix}/bci-{self.name}:{self.version_label}"

@property
def pretty_reference(self) -> str:
return f"{self.registry}/{self._registry_prefix}/bci-{self.name}:%OS_VERSION_ID_SP%"


def generate_disk_size_constraints(size_gb: int) -> str:
"""Creates the contents of a :file:`_constraints` file for OBS to require
Expand Down

0 comments on commit 0797736

Please sign in to comment.