feat(image): --image accepts name & substring, not just UUID (closes #190)#201
Merged
Conversation
…190) ConoHa3's image catalog ships VMI variants (vmi-docker-29.2-ubuntu-... -amd64 etc.) but no plain ubuntu-24.04, so README/sample suggestions like '--image ubuntu-24.04' previously failed with the user holding a 36-char UUID requirement. Add ImageAPI.FindImage(nameOrID): - UUID-shaped input → GetImage - Exact name match → that image (regardless of status) - Single substring match against active image names → that image - Multiple substring matches → error listing candidates - No match → "image %q not found, try `conoha image list`" Substring matching restricts to status=active so we don't surface half-baked uploads. Plug it into 'server create' so '--image ubuntu-24.04' resolves automatically when there is exactly one matching VMI in the user's catalog. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code review of #190 surfaced two consistency gaps: 1. Exact-name match was status-blind: an image stuck in queued/saving/ killed state could be returned to a caller (e.g. server create) that would then fail with an opaque API error mid-flow. Restrict the exact-name loop to active images so the error happens at resolution time with a clear "not found" instead. 2. FindImage("") fell through to substring matching where strings.Contains returns true against every name. A multi-image tenant got an "ambiguous" error; a single-image tenant got that one image silently. Reject the empty string up front with an actionable hint. Add image_edgecase_test.go covering: case-insensitive substring, exact-vs-substring precedence, empty rejection, and the killed-image guard. Existing TestImageFindImage continues to pass — its "exact name" case used an active image already. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Resolution behaviour
Test plan
Out of scope
This PR does not surface a plain `ubuntu-24.04` base entry in `image list` — that catalog content is owned by ConoHa, not the CLI. The samples README pattern of `--image ubuntu-24.04` will still need an actual matching catalog entry to succeed; this change just makes name-based resolution feasible when one exists.
🤖 Generated with Claude Code