Skip to content
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

Add group_id property to ComponentArtefactId model class #1168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions dso/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class ComponentArtefactId:
artefact: LocalArtefactId | None = None
artefact_kind: ArtefactKind | None = None
references: list[typing.Self] = dataclasses.field(default_factory=list)
group_id: str | None = None

@property
def key(self) -> str:
Expand All @@ -181,6 +182,22 @@ def key(self) -> str:
references_key,
)

@property
def effective_group_id(self) -> str:
'''
If the `group_id` was not explicitly set, this function uses the previous calculation of
the "group-id" as default fallback, which is comprised of the component-name, artefact-kind,
artefact-name as well as artefact-type, e.g.
"github.com/gardener/cc-utilsresourcejob-imageociImage".
'''
if self.group_id:
return self.group_id

return (
self.component_name + self.artefact_kind
+ self.artefact.artefact_name + self.artefact.artefact_type
)

def __hash__(self) -> int:
return hash(self.key)

Expand Down