Skip to content

fix(ecr): align image list columns to fixed widths (#195)#196

Merged
nathanhuh merged 2 commits into
DevopsArtFactory:mainfrom
SAY-5:fix/ecr-image-list-columns-195
May 6, 2026
Merged

fix(ecr): align image list columns to fixed widths (#195)#196
nathanhuh merged 2 commits into
DevopsArtFactory:mainfrom
SAY-5:fix/ecr-image-list-columns-195

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 28, 2026

Closes #195.

What

ECRImage.DisplayTitle rendered tag / digest / pushed / size / status
as a space-padded but variable-width string. When tags had different
lengths the digest column started at a different visual position per
row, making the list hard to scan.

Fix

Pin each column to a fixed rune-width and pad/truncate accordingly:

Column Width Notes
tag 30 left-pad; truncate with on overflow
digest 19 shortDigest already produces ≤ 19 chars
pushed 16 2006-01-02 15:04
size 9 right-aligned for trailing-unit readability
status variable last column — no later column to misalign

New fitColumn(s, width) helper does the pad/truncate. Width is
measured in runes, not bytes, so a multi-byte tag character
doesn't break alignment.

Acceptance criteria:

  • Rows visually column-aligned.
  • Long tags don't push later columns out — truncated with .
  • Existing stale/untagged status suffix untouched (still last,
    free-form).
  • Tests cover mixed-length tags and verify digest column alignment.

Tests

internal/services/aws/ecr_model_test.go (new):

  • TestECRImageDisplayTitleColumnsAlign — three rows with short /
    medium / long tags all place the digest substring at the same
    rune position. Long tag truncates with the ellipsis marker.
    (Bytes can disagree because is 3 UTF-8 bytes / 1 rune; the
    test compares rune positions because that's what aligns visually
    in a terminal.)
  • TestFitColumn — 6 sub-cases pinning the helper's contract
    (pad / exact / truncate / unicode / width=0 / width=1 overflow).

Verification

  • go build ./...
  • go test ./... → all 10 packages pass.

)

Closes DevopsArtFactory#195.

`ECRImage.DisplayTitle` rendered tag/digest/pushed/size/status as a
space-padded but variable-width string. When tags had different
lengths the digest column started at a different visual position
per row, making the list hard to scan.

Pin each column to a fixed rune-width and pad/truncate accordingly:

  - tag       30 (truncates with '…' on overflow)
  - digest    19 (shortDigest already produces <= 19 chars)
  - pushed    16 ("2006-01-02 15:04")
  - size       9 (right-aligned for trailing-unit readability)
  - status     variable suffix (no later column to misalign)

A new `fitColumn(s, width)` helper does the pad-or-truncate work.
Width is measured in runes (not bytes), so a multi-byte tag character
doesn't break alignment.

Tests
- `TestECRImageDisplayTitleColumnsAlign`: three rows with short /
  medium / long tags all place the digest substring at the same rune
  position. Long tag truncates with the ellipsis marker.
- `TestFitColumn`: 6 sub-cases pinning the helper's contract
  (pad / exact / truncate / unicode / width=0 / width=1 overflow).

Verified locally: `go test ./...` → all 10 packages pass.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@YoungJinJung
Copy link
Copy Markdown
Contributor

/q review

Copy link
Copy Markdown
Contributor

@amazon-q-developer amazon-q-developer Bot left a comment

Choose a reason for hiding this comment

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

Review Summary

This PR successfully addresses issue #195 by implementing fixed-width column formatting for the ECR image list, making it easier to scan when tags have varying lengths. The solution is well-designed with proper handling of edge cases and comprehensive test coverage.

Critical Change Requested

  • Documentation error in fitColumn function comment that misrepresents the padding behavior (identified above)

Implementation Strengths

The fix includes solid engineering practices: column width constants, rune-aware string handling for proper Unicode support, comprehensive test coverage (alignment verification and helper function tests), and proper edge case handling in fitColumn (width <= 0, exact match, overflow, width=1).


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

Comment thread internal/services/aws/ecr_model.go Outdated
Comment on lines +81 to +84
// fitColumn left-pads `s` to exactly `width` runes so subsequent columns
// align in the rendered list. Long values are truncated with a single
// trailing ellipsis. Width is measured in runes (not bytes) so multi-byte
// tag characters don't break the layout.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛑 Documentation Error: Comment states "left-pads" but implementation right-pads (adds spaces to the right of the string). This will confuse future maintainers about the function's behavior.

Suggested change
// fitColumn left-pads `s` to exactly `width` runes so subsequent columns
// align in the rendered list. Long values are truncated with a single
// trailing ellipsis. Width is measured in runes (not bytes) so multi-byte
// tag characters don't break the layout.
// fitColumn right-pads `s` to exactly `width` runes so subsequent columns
// align in the rendered list. Long values are truncated with a single
// trailing ellipsis. Width is measured in runes (not bytes) so multi-byte
// tag characters don't break the layout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@SAY-5 Can you fix above comment? :) Thank you for contribute.

Copy link
Copy Markdown
Contributor

@YoungJinJung YoungJinJung left a comment

Choose a reason for hiding this comment

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

Please modify q developer bot review and merge this PR.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5
Copy link
Copy Markdown
Contributor Author

SAY-5 commented May 3, 2026

Fixed the doc comment in 349d1dc.

@SAY-5
Copy link
Copy Markdown
Contributor Author

SAY-5 commented May 3, 2026

Addressed in 349d1dc: comment now reads 'right-pads' per the suggestion.

Copy link
Copy Markdown
Contributor

@nathanhuh nathanhuh left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks for contributing, @SAY-5 !

@nathanhuh nathanhuh merged commit e6df8ca into DevopsArtFactory:main May 6, 2026
1 check passed
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.

fix: align ECR image list columns

3 participants