-
Notifications
You must be signed in to change notification settings - Fork 0
Encode release stream in image target UID #554
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
Merged
+113
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -14,11 +14,12 @@ | |
| from posit_bakery.config.image.build_os import DEFAULT_PLATFORMS | ||
| from posit_bakery.config.image.build_secret import BuildSecret | ||
| from posit_bakery.config.image.parsed_version import version_sort_key | ||
| from posit_bakery.config.image.posit_product.const import ReleaseStreamEnum | ||
| from posit_bakery.config.registry import Registry, BaseRegistry | ||
| from posit_bakery.config.repository import Repository | ||
| from posit_bakery.config.tag import TagPattern, TagPatternFilter | ||
| from posit_bakery.const import OCI_LABEL_PREFIX, POSIT_LABEL_PREFIX, REGEX_IMAGE_TAG_SUFFIX_ALLOWED_CHARACTERS_PATTERN | ||
| from posit_bakery.error import BakeryToolRuntimeError, BakeryFileError | ||
| from posit_bakery.error import BakeryError, BakeryToolRuntimeError, BakeryFileError | ||
| from posit_bakery.image.image_metadata import MetadataFile, BuildMetadata | ||
| from posit_bakery.settings import SETTINGS | ||
|
|
||
|
|
@@ -285,14 +286,34 @@ def __str__(self): | |
| @computed_field | ||
| @property | ||
| def uid(self) -> str: | ||
| """Generate a unique identifier for the target based on its properties.""" | ||
| """Generate a unique identifier for the target. | ||
|
|
||
| The stream is appended for development versions so a dev build and a release | ||
| build of the same version never share a UID. Release UIDs stay unsuffixed. | ||
| """ | ||
| u = f"{self.image_name}-{self.image_version.name}" | ||
| if self.image_variant: | ||
| u += f"-{self.image_variant.name}" | ||
| if self.image_os: | ||
| u += f"-{self.image_os.name}" | ||
| if self.release_stream != ReleaseStreamEnum.RELEASE: | ||
| u += f"-{self.release_stream.value}" | ||
|
Comment on lines
+299
to
+300
Contributor
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. Smort |
||
| return re.sub("[ .+/]", "-", u).lower() | ||
|
|
||
| @property | ||
| def release_stream(self) -> ReleaseStreamEnum: | ||
| """The release stream for this target, defaulting to ``release`` when unset.""" | ||
| stream = self.image_version.metadata.get("release_stream") | ||
| if stream is None: | ||
| return ReleaseStreamEnum.RELEASE | ||
| try: | ||
| return ReleaseStreamEnum(stream) | ||
| except ValueError as e: | ||
| raise BakeryError( | ||
| f"Invalid release_stream {stream!r} for {self}. " | ||
| f"Expected one of: {', '.join(s.value for s in ReleaseStreamEnum)}." | ||
| ) from e | ||
|
|
||
| @property | ||
| def image_name(self) -> str: | ||
| """Return the name of the image.""" | ||
|
|
@@ -371,9 +392,7 @@ def tag_template_values(self) -> dict[str, str]: | |
| "Variant": self.image_variant.tagDisplayName if self.image_variant else "", | ||
| "OS": self.image_os.tagDisplayName if self.image_os else "", | ||
| "Name": self.image_name, | ||
| "Stream": str(v.value if hasattr(v, "value") else v) | ||
| if (v := self.image_version.metadata.get("release_stream")) | ||
| else "", | ||
| "Stream": self.release_stream.value if self.image_version.metadata.get("release_stream") else "", | ||
| } | ||
|
|
||
| @property | ||
|
|
||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smort