(ctx context.Context, dockerClient *client.Client, t TargetBuild, opts image.PushOptions, progress bool)
| 387 | } |
| 388 | |
| 389 | func pushImage(ctx context.Context, dockerClient *client.Client, t TargetBuild, opts image.PushOptions, progress bool) error { |
| 390 | fmt.Printf("Pushing %s\n", t.DockerImageTag) |
| 391 | opts.Platform = &ocispec.Platform{ |
| 392 | OS: t.OS, |
| 393 | Architecture: t.Arch, |
| 394 | } |
| 395 | out, err := dockerClient.ImagePush(ctx, t.DockerImageTag, opts) |
| 396 | if err != nil { |
| 397 | return fmt.Errorf("failed to push Docker image: %v", err) |
| 398 | } |
| 399 | defer out.Close() |
| 400 | |
| 401 | if !progress { |
| 402 | _, err = io.Copy(io.Discard, out) |
| 403 | if err != nil { |
| 404 | return err |
| 405 | } |
| 406 | return nil |
| 407 | } |
| 408 | |
| 409 | // Create a progress reader to display the download progress |
| 410 | pr := &dockerProgressReader{ |
| 411 | decoder: json.NewDecoder(out), |
| 412 | layerPushedByID: map[string]int64{}, |
| 413 | } |
| 414 | if _, err := io.Copy(io.Discard, pr); err != nil { |
| 415 | return err |
| 416 | } |
| 417 | if pr.bar != nil { |
| 418 | _ = pr.bar.Finish() |
| 419 | pr.bar.Close() |
| 420 | } |
| 421 | |
| 422 | return nil |
| 423 | } |
| 424 | |
| 425 | func getDockerToken(ctx context.Context, ref reference.Named, version, team, username, password string, insecureSkipVerify bool) (string, error) { |
| 426 | // https://distribution.github.io/distribution/spec/auth/token/#how-to-authenticate |
no test coverage detected