[deckhouse-cli] d8 cr login and --username/--password flags#377
Merged
Conversation
Signed-off-by: Pavel Okhlopkov <pavel.okhlopkov@flant.com>
- `cr login` now sends an authenticated `GET /v2/`, so a wrong password on a basic-auth (htpasswd) registry fails instead of landing in the Docker config. - `transport.NewWithContext` only validates bearer-token registries; the explicit `/v2/` probe covers the basic-auth case it skips. - A lone `--username` or `--password` on non-login commands now errors `must be used together` instead of being silently dropped into a confusing 401. - `login_test.go` covers basic and bearer registries, each with correct and wrong credentials. Signed-off-by: Roman Berezkin <roman.berezkin@flant.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.
What
Adds
d8 cr login— a new subcommand that authenticates against a containerregistry and persists the credentials to the Docker config
(
~/.docker/config.json, honouring$DOCKER_CONFIGand any configuredcredential helper/store), exactly like
docker login.Also adds persistent
-u/--usernameand-p/--passwordflags to thed8 crroot so one-off credentials can be passed to any command without aprior login.
Why
packagecmdalready callsd8 delivery-kit cr login <registry> --username … --password …; this PR provides the backing command.~/.docker/config.jsonon the host (--username/--password).d8 login(Kubernetes OIDC),which is unrelated to registry auth.
Changes
internal/cr/cmd/basic/login.god8 cr logincobra command. Verifies credentials via the registry auth handshake, then writes them throughdocker/cli's credential store. Interactive prompts when flags are omitted; password is read without echo on a TTY.internal/cr/internal/registry/login.goregistry.Logindomain function. Performs a registry ping + token exchange to validate credentials before persisting. Normalises Docker Hub to its canonicalhttps://index.docker.io/v1/key.internal/cr/internal/registry/options.goTransportfield toOptions(so--insecureis honoured during login), andNewStaticKeychainfor inline credentials.internal/cr/cmd/rootflags.go-u/--usernameand-p/--passwordflags; builds a static keychain when--usernameis set so credentials override the Docker config for the current invocation.internal/cr/cmd/rootflagnames/names.goUsernameandPasswordconstants.internal/cr/cmd/cr.gologinsubcommand; fixes help text to referenced8 cr loginand--username/--passwordinstead of the unrelatedd8 login.internal/cr/README.mdlogin, new global flags, and a login examples cheat-sheet.Usage