Repository navigation
feat(github-cli)!: add runtime authentication and explicit extension modes - #1606
Emilien Escalle (neilime) wants to merge 9 commits into
Conversation
c219e7c to
2d610ba
Compare
2d610ba to
fb8256f
Compare
15585e9 to
b44f825
Compare
|
Hi @Kaniska244 any chance to have this PR merged? Thank you :) |
b44f825 to
f1345db
Compare
f8549e5 to
4e3dffb
Compare
|
Hi @Kaniska244, here is a kindly reminder, hoping having this PR merged one day :) Thanks |
|
Hello Emilien Escalle (@neilime), apologies this is my fault as I've been meaning to look at this but haven't had a chance. I'll try to review this within the week. |
|
Emilien Escalle (@neilime) Would you be able to break this PR up, as I'm struggling to review it given the size and number of files touched? |
6504080 to
9c20ae6
Compare
9c20ae6 to
ad1b835
Compare
|
Abdurrahmaan Iqbal (@abdurriq) done: 6 atomic commits (atomic as much as I can) with their own purpose |
|
I noticed some inconsistencies in double-quotes around params and the logic between |
Not a strict 1:1 copy on purpose: the top-level script now only orchestrates the install/auth/extensions scopes, so the previous logic was split into dedicated scripts. Your concern about drift was valid though, and I found one real inconsistency in the installExtensionsFromGit path and fixed it. Aside from that, the remaining differences are mostly cleanup, plus one small fallback fix in the GitHub CLI installer. |
1ac67b7 to
b909ce6
Compare
b909ce6 to
cdec3c5
Compare
|
Abdurrahmaan Iqbal (@abdurriq) Hi, any news for merging this PR? Thanks |
d3ccc36 to
f2edbb4
Compare
|
Hi Abdurrahmaan Iqbal (@abdurriq) this is a kindly reminder for my PR :) |
|
Emilien Escalle (@neilime) Apologies, this totally slipped my mind. I'll try to prioritise this and review it by mid-next week. |
|
Copilot resolve the merge conflicts in this pull request |
Abdurrahmaan Iqbal (@abdurriq) No problem, I can rebase and fix conflict if it can help |
|
Emilien Escalle (@neilime) Yes, please. |
…ization Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
f2edbb4 to
f6c8bd6
Compare
Done. |
| exit 1 | ||
| validate_configuration() { | ||
| if has_unsupported_extensions_configuration; then | ||
| die "Unsupported extensions configuration. When 'extensions' is set, enable 'authOnSetup' to install after authentication or set 'installExtensionsFromGit' to true to clone extensions during feature setup." |
There was a problem hiding this comment.
With both new options defaulting to false, validate_configuration now exits before installing gh, so anyone pinned to :1 of this feature using the existing {"extensions": "..."} configuration, including the README example, will have their config broken. Could the default keep the previous attempt-gh-then-clone behavior when neither option is set?
| } | ||
|
|
||
| main() { | ||
| if is_auth_setup_complete || ! is_gh_available; then |
There was a problem hiding this comment.
This early exit also skips deferred extension installation, not just auth, so a marker left in a persistent home causes extensions added on a rebuild to be ignored. Could the hook process pending extensions.env before honouring the marker, or tie the marker to the current extension config?
Restore default extension installation with a Git fallback, reject clones without runnable entry points, and rerun deferred installs when their configuration changes. Add regression coverage and regenerate feature documentation. Validated with five container tests, focused regression tests, ShellCheck, and metadata validation. Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
| die "Cannot install extension '${EXTENSION}' with 'gh': GitHub CLI is unavailable." | ||
| fi | ||
|
|
||
| if ! gh_is_authenticated; then |
There was a problem hiding this comment.
Could we drop the gh auth status check and always attempt gh extension install, keeping the git fallback for when it fails? gh extension install already exits 0 when the extension is already installed, so the extension list pre-check may not be needed either.
|
|
||
| attempt_login() { | ||
| if [ -n "${RESOLVED_AUTH_TOKEN}" ]; then | ||
| printf '%s' "${RESOLVED_AUTH_TOKEN}" | gh auth login --with-token > /dev/null 2>&1 || true |
There was a problem hiding this comment.
When GH_TOKEN or GITHUB_TOKEN is set, gh uses it directly and refuses gh auth login --with-token with the error "The value of the GH_TOKEN environment variable is being used for authentication". That means this line only runs when the token is invalid, and will always fails.
Could we skip the --with-token call when the token comes from the environment, and print a warning to stderr when gh auth status fails with a token set?
|
Added a couple comments related to auth decisions. Also, backward compatibility is a bit tricky here; what do you think about scrapping that entirely and just bumping up to the next major version? That might simplify things a bit. |
Use environment tokens directly, warn on authentication failures, and delegate extension installation checks to gh. Preserve deferred installation retries and configuration-aware completion markers. BREAKING CHANGE: extensions require authOnSetup or installExtensionsFromGit. Remove the automatic git fallback and gh compatibility wrapper, and release the feature as 2.0.0.
Release the GitHub CLI feature as 2.0.0, with optional authentication at shell startup and explicit extension installation modes. Runtime authentication lets extension installation use tokens supplied through settings such as
remoteEnv.Breaking change
A nonempty
extensionsoption now requires at least one of:authOnSetup=true: install throughgh extension installafter runtime authentication. Supports script and precompiled extensions.installExtensionsFromGit=true: clone script extensions during the container build. Each repository must contain an executable at its root matching the repository name.Both options default to
false. Setting both installs script extensions during the build and enables authentication at shell startup. An extensions-only configuration fails before installing GitHub CLI. The automatic git fallback and thegh extension listcompatibility wrapper are removed.Examples and generated documentation now use
ghcr.io/devcontainers/features/github-cli:2.Authentication and extension behavior
GH_TOKENorGITHUB_TOKENdirectly, without callinggh auth login --with-tokenor persisting the environment token. Warn on stderr when authentication fails with a token set.gh auth loginonly when authentication is needed, no environment token is set, and a terminal is available.gh extension installwithout redundant authentication or extension-list checks in the extension installer.Validation
devcontainer features test --project-folder "$PWD" --features github-cli --base-image ubuntu:noble: all 7 tests passed in 287 seconds, including the Debian trixie and Ubuntu resolute scenarios.gh, configuration rejection, shell syntax, JSON, documentation links/examples, andgit diff --check.devcontainers/action@v1generator.