MCPcopy Index your code
hub / github.com/docker/cli / loginWithDeviceCodeFlow

Function loginWithDeviceCodeFlow

cli/command/registry/login.go:285–320  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

283}
284
285func loginWithDeviceCodeFlow(ctx context.Context, dockerCLI command.Cli) (msg string, _ error) {
286 store := dockerCLI.ConfigFile().GetCredentialsStore(registry.IndexServer)
287 authConfig, err := manager.NewManager(store).LoginDevice(ctx, dockerCLI.Err())
288 if err != nil {
289 return "", err
290 }
291
292 response, err := loginWithRegistry(ctx, dockerCLI.Client(), client.RegistryLoginOptions{
293 Username: authConfig.Username,
294 Password: authConfig.Password,
295 ServerAddress: authConfig.ServerAddress,
296
297 // TODO(thaJeztah): Are these expected to be included?
298 // Auth: authConfig.Auth,
299 IdentityToken: authConfig.IdentityToken,
300 RegistryToken: authConfig.RegistryToken,
301 })
302 if err != nil {
303 return "", err
304 }
305
306 if err = storeCredentials(dockerCLI.ConfigFile(), registrytypes.AuthConfig{
307 Username: authConfig.Username,
308 Password: authConfig.Password,
309 ServerAddress: authConfig.ServerAddress,
310
311 // TODO(thaJeztah): Are these expected to be included?
312 Auth: authConfig.Auth,
313 IdentityToken: authConfig.IdentityToken,
314 RegistryToken: authConfig.RegistryToken,
315 }); err != nil {
316 return "", err
317 }
318
319 return response.Auth.Status, nil
320}
321
322func storeCredentials(cfg *configfile.ConfigFile, authConfig registrytypes.AuthConfig) error {
323 creds := cfg.GetCredentialsStore(authConfig.ServerAddress)

Callers 1

loginUserFunction · 0.85

Calls 7

loginWithRegistryFunction · 0.85
storeCredentialsFunction · 0.85
GetCredentialsStoreMethod · 0.80
LoginDeviceMethod · 0.80
ConfigFileMethod · 0.65
ErrMethod · 0.65
ClientMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…