-
Notifications
You must be signed in to change notification settings - Fork 82
fix(docker): Improve user name detection when tagging clp-package dev image (fixes #1371). #1373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdjusts the build script’s user resolution order to whoami, then id --user --name, else "unknown", and uses the resolved value in the Docker image tag as dev-${user}-${short_id}. No other logic paths are changed. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
tools/docker-images/clp-package/build.sh
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: package-image
- GitHub Check: rust-checks (ubuntu-24.04)
- GitHub Check: rust-checks (ubuntu-22.04)
- GitHub Check: rust-checks (macos-15)
- GitHub Check: lint-check (ubuntu-24.04)
- GitHub Check: lint-check (macos-15)
user="${USER:-$(whoami 2>/dev/null)}" \ | ||
|| user=$(id --user --name 2>/dev/null) \ | ||
|| user=$(id --user 2>/dev/null) \ | ||
|| user="unknown"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore POSIX-friendly id
fallbacks.
id --user --name
/id --user
are GNU-only; macOS and BusyBox reject them, so the script now falls all the way to "unknown"
on those platforms. The previous id -un
/id -u
path worked there, so this is a regression. Please retain the short-option fallbacks (or probe for GNU support) before giving up on resolving the username.
- user="${USER:-$(whoami 2>/dev/null)}" \
- || user=$(id --user --name 2>/dev/null) \
- || user=$(id --user 2>/dev/null) \
+ user="${USER:-$(whoami 2>/dev/null)}" \
+ || user=$(id --user --name 2>/dev/null) \
+ || user=$(id -un 2>/dev/null) \
+ || user=$(id --user 2>/dev/null) \
+ || user=$(id -u 2>/dev/null) \
|| user="unknown";
🤖 Prompt for AI Agents
In tools/docker-images/clp-package/build.sh around lines 51-54, the current
fallbacks use GNU-only long id options and break on macOS/BusyBox; restore
POSIX-friendly fallbacks by trying id -un and id -u first (then the GNU
long-option forms if desired), then whoami as a next fallback, and finally
"unknown"; implement these attempts with || chains so the script resolves the
username on non-GNU systems before giving up.
Description
This change improves how the username is detected when tagging the clp‑package development Docker image, addressing issue #1371:
user
from env varUSER
whoami
whoami
binary missing), runid --user --name
id --user
to just get the user idid
binary missing), useunknown
as the fallback.Checklist
breaking change.
Validation performed
clp-package:dev-<username>-<hash>
by checkingdocker image ls
USER
env var is missing and the username is missing from/etc/passwd
, and found the image was tagged withclp-package:dev-<username-id>-<hash>
by checkingdocker image ls
:Summary by CodeRabbit