pull.go 818 B

123456789101112131415161718192021222324252627282930
  1. package client
  2. import (
  3. "golang.org/x/net/context"
  4. "github.com/docker/docker/pkg/jsonmessage"
  5. "github.com/docker/engine-api/types"
  6. )
  7. // ImagePullPrivileged pulls the image and displays it to the output
  8. func (cli *DockerCli) ImagePullPrivileged(ctx context.Context, authConfig types.AuthConfig, ref string, requestPrivilege types.RequestPrivilegeFunc, all bool) error {
  9. encodedAuth, err := EncodeAuthToBase64(authConfig)
  10. if err != nil {
  11. return err
  12. }
  13. options := types.ImagePullOptions{
  14. RegistryAuth: encodedAuth,
  15. PrivilegeFunc: requestPrivilege,
  16. All: all,
  17. }
  18. responseBody, err := cli.client.ImagePull(ctx, ref, options)
  19. if err != nil {
  20. return err
  21. }
  22. defer responseBody.Close()
  23. return jsonmessage.DisplayJSONMessagesStream(responseBody, cli.out, cli.outFd, cli.isTerminalOut, nil)
  24. }