MCPcopy Index your code
hub / github.com/cloudquery/cloudquery / pushImage

Function pushImage

cli/internal/publish/plugins.go:389–423  ·  view source on GitHub ↗
(ctx context.Context, dockerClient *client.Client, t TargetBuild, opts image.PushOptions, progress bool)

Source from the content-addressed store, hash-verified

387}
388
389func 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
425func 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

Callers 1

PublishToDockerRegistryFunction · 0.85

Calls 4

PrintfMethod · 0.80
ErrorfMethod · 0.80
CloseMethod · 0.65
FinishMethod · 0.65

Tested by

no test coverage detected