manage: extract _fetch_image_info to reduce duplication#2217
Draft
ideaship wants to merge 1 commit intochecksum-fetch-retryfrom
Draft
manage: extract _fetch_image_info to reduce duplication#2217ideaship wants to merge 1 commit intochecksum-fetch-retryfrom
ideaship wants to merge 1 commit intochecksum-fetch-retryfrom
Conversation
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>
There was a problem hiding this comment.
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 doingstrip().split()[:2]so that a malformed marker produces a clear, custom error instead of an unhandledValueErrorfrom 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.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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 CLI • Give Feedback 💬