Skip to content

Commit

Permalink
do not release tracks with expired end_of_life values
Browse files Browse the repository at this point in the history
  • Loading branch information
linostar committed Sep 6, 2024
1 parent 33300f2 commit 6114513
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 9 additions & 0 deletions src/image/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@
print(f"Track {track} will be created for the 1st time")
all_releases[track] = {}

expired = False
for risk, value in risks.dict(exclude_none=True).items():
if risk in ["end-of-life", "end_of_life"]:
if all_releases[track]["expired"]:
# skip tracks that have expired end_of_life values
expired = True
break
all_releases[track]["end-of-life"] = value
continue

Expand All @@ -89,6 +94,10 @@
print(f"Channel {tag} points to {value}")
tag_mapping_from_trigger[tag] = value

if expired:
# remove the track since it has an expired end_of_life value
del all_releases[track]

print(
"Going to update channels according to the following:\n"
f"{json.dumps(tag_mapping_from_trigger, indent=2)}"
Expand Down
15 changes: 7 additions & 8 deletions src/image/utils/schema/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class ImageUploadReleaseSchema(pydantic.BaseModel):
risks: List[Literal["edge", "beta", "candidate", "stable"]]

class Config:
extra = pydantic.Extra.forbid
extra = pydantic.Extra.allow

@pydantic.validator("end_of_life")
def ensure_still_supported(cls, v: datetime) -> datetime:
def ensure_still_supported(cls, v: datetime, values) -> datetime:
"""ensure that the end of life isn't reached."""
if v < datetime.now(timezone.utc):
raise ImageReachedEol("This track has reached its end of life")

values["expired"] = (v < datetime.now(timezone.utc))
return v


Expand All @@ -55,7 +55,7 @@ class ChannelsSchema(pydantic.BaseModel):
edge: Optional[str]

class Config:
extra = pydantic.Extra.forbid
extra = pydantic.Extra.allow

@pydantic.validator("stable", "candidate", "beta", "edge", pre=True)
def _check_risks(cls, values: List) -> str:
Expand All @@ -67,10 +67,9 @@ def _check_risks(cls, values: List) -> str:
return values

@pydantic.validator("end_of_life")
def ensure_still_supported(cls, v: datetime) -> datetime:
def ensure_still_supported(cls, v: datetime, values) -> datetime:
"""ensure that the end of life isn't reached."""
if v < datetime.now(timezone.utc):
raise ImageReachedEol("This track has reached its end of life")
values["expired"] = (v < datetime.now(timezone.utc))
return v


Expand Down

0 comments on commit 6114513

Please sign in to comment.