Skip to content

Commit

Permalink
Add unique identifier in version tags
Browse files Browse the repository at this point in the history
* Add a unique identifier in version tags to avoid problems like rename
  etc... this creates a unique way to identify which tag user have
  installed.
* Right now add the first image digest as the unique identifier, but
  since cloud uses a uuid v4 we should in future move to uuid v4
  • Loading branch information
JoaoMario109 committed Apr 26, 2024
1 parent 6be4d16 commit dd248a4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions blueos_repository/extension/extension.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import uuid
from typing import Dict, List

import aiohttp
Expand Down Expand Up @@ -148,7 +149,16 @@ async def __create_version_from_tag_blob(self, version_tag: Tag, blob: Blob) ->
Logger.warning(self.identifier, str(error))
readme = str(error)

images = self.__extract_images_from_tag(version_tag)
if not images:
Logger.error(
self.identifier,
f"Could not find images associated with tag {version_tag.name} for extension {self.identifier}"
)

tag_identifier = str(uuid.uuid5(uuid.NAMESPACE_DNS, f"{self.identifier}.{version_tag.name}"))
return ExtensionVersion(
identifier=tag_identifier,
tag=version_tag.name,
type=labels.get("type", ExtensionType.OTHER),
website=links.pop("website", labels.get("website", None)),
Expand Down
3 changes: 3 additions & 0 deletions blueos_repository/extension/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class ExtensionVersion:
Represents a version of an extension.
Attributes:
identifier (str): Unique identifier of this tag version, in extension repository is the 256 sha digest from the
first compatible image, in BlueOS cloud is a uuid v4.
tag (Optional[str]): Tag of the version.
type (ExtensionType): Type of the extension.
website (str): URL to the extension's website.
Expand All @@ -105,6 +107,7 @@ class ExtensionVersion:
images (List[Image]): Images available for the extension.
"""

identifier: str # TODO - In future try to unify with identifiers coming from cloud
type: ExtensionType
website: str
images: List[Image]
Expand Down

0 comments on commit dd248a4

Please sign in to comment.