// PullImage pulls a Docker Image
PullImage pulls a Docker Image
// PullImage pulls a Docker Image
func (s *ImageService) PullImage(ctx context.Context, req *runtimeapi.PullImageRequest) (*runtimeapi.PullImageResponse, error) {
	img := req.GetImage().GetImage()
	imgPullOpts := types.ImagePullOptions{All: false}
	repository, err := GetRepository(img)
	if err != nil {
		return nil, err
	}
	authProvider, err := ResolveRepositoryAuthProvider(repository, s.authProviders)
	if err != nil {
		log.Println(err) 
	}
	if authProvider != nil {
		authResp, err := authProvider.Provide(ctx, &dockerregistryproxyv1.ProvideRequest{})
		if err != nil {
			return nil, err
		}
		regAuth := base64.StdEncoding.EncodeToString(
			[]byte(fmt.Sprintf(
				`{"username": "%s", "password": "%s"}`,
				authResp.GetUsername(),
				authResp.GetPassword(),
			)),
		)
		imgPullOpts.RegistryAuth = regAuth
	}
	out, err := s.client.ImagePull(ctx, img, imgPullOpts)
	if err != nil {
		return nil, err
	}
	scanner := bufio.NewScanner(out)
	for scanner.Scan() {
		os.Stdout.Write(scanner.Bytes())
	}
	out.Close()
	image, _, err := s.client.ImageInspectWithRaw(ctx, req.GetImage().GetImage())
	if err != nil {
		return nil, err
	}
	return &runtimeapi.PullImageResponse{
		ImageRef: image.ID,
	}, nil
}
func ( s * ImageService ) PullImage ( ctx context . Context , req * runtimeapi . PullImageRequest ) ( * runtimeapi . PullImageResponse , error ) { img := req . GetImage ( ) . GetImage ( ) imgPullOpts := types . ImagePullOptions { All : false } repository , err := GetRepository ( img ) if err != nil { return nil , err } authProvider , err := ResolveRepositoryAuthProvider ( repository , s . authProviders ) if err != nil { log . Println ( err ) } if authProvider != nil { authResp , err := authProvider . Provide ( ctx , & dockerregistryproxyv1 . ProvideRequest { } ) if err != nil { return nil , err } regAuth := base64 . StdEncoding . EncodeToString ( [ ] byte ( fmt . Sprintf ( `{"username": "%s", "password": "%s"}` , authResp . GetUsername ( ) , authResp . GetPassword ( ) , ) ) , ) imgPullOpts . RegistryAuth = regAuth } out , err := s . client . ImagePull ( ctx , img , imgPullOpts ) if err != nil { return nil , err } scanner := bufio . NewScanner ( out ) for scanner . Scan ( ) { os . Stdout . Write ( scanner . Bytes ( ) ) } out . Close ( ) image , _ , err := s . client . ImageInspectWithRaw ( ctx , req . GetImage ( ) . GetImage ( ) ) if err != nil { return nil , err } return & runtimeapi . PullImageResponse { ImageRef : image . ID , } , nil }
PullImage pulls a Docker Image
PullImage pulls a Docker Image
// Only warn for images that may not need authentication