devcontainers / devcontainers/features
[Feature Request][common-utils]: add updateUsername option to common-utils feature
まだ誰も着手していません。
- 主要言語
- Shell
- スター
- 1.5k
- フォーク
- 622
- 平均マージ
- 6日 53分
- マージ済み PR(30日)
- 9
説明
As per the comment in #535.
Add an updateUsername option that will update the users username based on the UID.
updateUsername bool Updates the username of the user who has the UID of userUid to the value contained in username. Default false
edit
thinking about this more, a better way to think about using this role is to separate out the userIdMode from the logic of the update or add. This would make the role work in two steps.
- Identify the user by 'userIdMode'
- Update or create user based on presence using 'userIdMode'.
Where 'userIdMode' is one of UID, ausername, or auto/automatic.
If the user exists, then the role updates, if not it adds.
It might be worth setting defaults to assume that the 'userIdMode' is UID and the default UID is 1000 so that the role works as expected on a second run if the user wants a different username. I'm kind of assuming a different username is the more likely scenario and that the user will use the base images that create a user with UID of 1000. Maybe somebody will say that isn't the best assumption.
It might also be worth adding multiple options for UID and GID so the vscode wizard can add or edit the existing users. Probably 1000 & 1001 and 1002. It might be a bug in the GitHub devcontainers vscode implementation that users can't manually set a value, or maybe that is intentional as part of the devcontainers spec. I'm not sure if 'option' the word necessarily implies 'every possible value' and actually I'm pretty sure it doesn't, but I'm not too familiar with the spec.
Anyway, I think we've Zuckerberg'd [TM, patent pending, lolol] this pretty well. With the issues I've created and comments we can probably move all user related activities into a separate feature 'users' feature, I'm not stuck on the name so feel free to suggest alternatives, that is well documented and specified.
I'll probably work on this in the near future, but if somebody has already done it or is currently doing it let me know so I don't duplicate work. For all I know somebody could do this while I'm in a meeting now... So if anybody wanted to know what I'm planning on doing, all they'd have to do is follow my GitHub account. :) Yup.
end edit
The way the feature currently works is that it will create a new user if the username is not already on the system and modifies the user otherwise, setting the UID, GID, etc. The new implementation would allow users to update the username if the UID is present on the system. Possibly also update the GID if desired by the implementers.
TODO: confirm behavior for automatic mode.
The behavior is the same regardless of the way username is determined.
https://github.com/devcontainers/features/blob/main/src/common-utils/main.sh#L345
I think what automatic tries to do is to sync the username with the remote username if it isn't root and tries to find one of the 'option' usernames if it is root and then uses vscode if it can't find an existing option user.
https://github.com/devcontainers/features/blob/main/src/common-utils/main.sh#L323
It might be worth adding a `modifyUsername` parameter so that users can update the username instead of assume the intention is to create a new user when the username doesn't match the username of the base image.
_Originally posted by @raymond-chetty in https://github.com/devcontainers/features/pull/535#discussion_r1181121433_
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず src/common-utils/main.sh の323行目と345行目付近を読み、自動的なユーザー名の選択と現在の更新動作を理解します。実装する前に、userIdMode、UID/GID の処理、デフォルト値、自動モードに関する未解決の問題を解決します。合意した動作で識別されたユーザーの更新または作成がサポートされ、文書化されていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- shell
- 領域
- devops
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100