Skip to content

manage: extract _fetch_image_info to reduce duplication#2217

Draft
ideaship wants to merge 1 commit intochecksum-fetch-retryfrom
manage-image-info-refactor
Draft

manage: extract _fetch_image_info to reduce duplication#2217
ideaship wants to merge 1 commit intochecksum-fetch-retryfrom
manage-image-info-refactor

Conversation

@ideaship
Copy link
Copy Markdown
Contributor

ImageClusterapi, ImageClusterapiGardener, and ImageOctavia all share
the same marker-fetch and checksum-fetch sequence: fetch a marker
file, parse the date and image filename, construct the image URL,
fetch the .CHECKSUM file, and log each step. This identical block
was repeated verbatim in all three take_action() implementations.

Extract this sequence into a private _fetch_image_info(base_url,
marker_url) helper that returns (date, image_filename, url, checksum).
Callers that need the image filename for version extraction
(ImageClusterapi, ImageClusterapiGardener) unpack it; ImageOctavia
discards it with _.

ImageGardenlinux is deliberately excluded: it constructs the image
URL directly from a known pattern rather than fetching a marker file,
so it shares only the checksum-fetch half of the pattern and does not
fit this helper without contortion.

AI-assisted: Claude Code
Signed-off-by: Roger Luethi luethi@osism.tech


Stack created with GitHub Stacks CLIGive Feedback 💬

ImageClusterapi, ImageClusterapiGardener, and ImageOctavia all share
the same marker-fetch and checksum-fetch sequence: fetch a marker
file, parse the date and image filename, construct the image URL,
fetch the .CHECKSUM file, and log each step. This identical block
was repeated verbatim in all three take_action() implementations.

Extract this sequence into a private _fetch_image_info(base_url,
marker_url) helper that returns (date, image_filename, url, checksum).
Callers that need the image filename for version extraction
(ImageClusterapi, ImageClusterapiGardener) unpack it; ImageOctavia
discards it with _.

ImageGardenlinux is deliberately excluded: it constructs the image
URL directly from a known pattern rather than fetching a marker file,
so it shares only the checksum-fetch half of the pattern and does not
fit this helper without contortion.

AI-assisted: Claude Code
Signed-off-by: Roger Luethi <luethi@osism.tech>
@ideaship ideaship marked this pull request as draft April 27, 2026 14:06
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • In _fetch_image_info, consider validating the number of whitespace-separated fields in the marker body before doing strip().split()[:2] so that a malformed marker produces a clear, custom error instead of an unhandled ValueError from tuple unpacking.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `_fetch_image_info`, consider validating the number of whitespace-separated fields in the marker body before doing `strip().split()[:2]` so that a malformed marker produces a clear, custom error instead of an unhandled `ValueError` from tuple unpacking.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant