(ctx context.Context, dockerCLI command.Cli)
| 283 | } |
| 284 | |
| 285 | func 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 | |
| 322 | func storeCredentials(cfg *configfile.ConfigFile, authConfig registrytypes.AuthConfig) error { |
| 323 | creds := cfg.GetCredentialsStore(authConfig.ServerAddress) |
no test coverage detected
searching dependent graphs…