本文整理汇总了Golang中github.com/fsouza/go-dockerclient.PullImageOptions.RawJSONStream方法的典型用法代码示例。如果您正苦于以下问题:Golang PullImageOptions.RawJSONStream方法的具体用法?Golang PullImageOptions.RawJSONStream怎么用?Golang PullImageOptions.RawJSONStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/fsouza/go-dockerclient.PullImageOptions
的用法示例。
在下文中一共展示了PullImageOptions.RawJSONStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: LoadImage
// LoadImage checks the client for an image matching from. If not found,
// attempts to pull the image and then tries to inspect again.
func (e *ClientExecutor) LoadImage(from string) (*docker.Image, error) {
image, err := e.Client.InspectImage(from)
if err == nil {
return image, nil
}
if err != docker.ErrNoSuchImage {
return nil, err
}
if !e.AllowPull {
glog.V(4).Infof("image %s did not exist", from)
return nil, docker.ErrNoSuchImage
}
repository, tag := docker.ParseRepositoryTag(from)
if len(tag) == 0 {
tag = "latest"
}
glog.V(4).Infof("attempting to pull %s with auth from repository %s:%s", from, repository, tag)
// TODO: we may want to abstract looping over multiple credentials
auth, _ := e.AuthFn(repository)
if len(auth) == 0 {
auth = append(auth, credentialprovider.LazyAuthConfiguration{})
}
if e.LogFn != nil {
e.LogFn("Image %s was not found, pulling ...", from)
}
var lastErr error
outputProgress := func(s string) {
e.LogFn("%s", s)
}
for _, config := range auth {
// TODO: handle IDs?
pullImageOptions := docker.PullImageOptions{
Repository: repository,
Tag: tag,
OutputStream: imageprogress.NewPullWriter(outputProgress),
RawJSONStream: true,
}
if glog.V(5) {
pullImageOptions.OutputStream = os.Stderr
pullImageOptions.RawJSONStream = false
}
authConfig := docker.AuthConfiguration{Username: config.Username, ServerAddress: config.ServerAddress, Password: config.Password}
if err = e.Client.PullImage(pullImageOptions, authConfig); err == nil {
break
}
lastErr = err
continue
}
if lastErr != nil {
return nil, fmt.Errorf("unable to pull image (from: %s, tag: %s): %v", repository, tag, lastErr)
}
return e.Client.InspectImage(from)
}
示例2: pullImage
func pullImage(client DockerClient, name string, authConfig docker.AuthConfiguration) error {
logProgress := func(s string) {
glog.V(0).Infof("%s", s)
}
opts := docker.PullImageOptions{
Repository: name,
OutputStream: imageprogress.NewPullWriter(logProgress),
RawJSONStream: true,
}
if glog.Is(5) {
opts.OutputStream = os.Stderr
opts.RawJSONStream = false
}
err := client.PullImage(opts, authConfig)
if err == nil {
return nil
}
return err
}
示例3: PullImage
// PullImage will pull the localkube image on the connected Docker daemon
func (d *Controller) PullImage(imageTag string, silent bool) error {
pullOpts := docker.PullImageOptions{
Repository: LocalkubeImageName,
Tag: imageTag,
}
in, out := io.Pipe()
// print pull progress if not silent
if !silent {
pullOpts.RawJSONStream = true
pullOpts.OutputStream = out
outFd, isTerminal := term.GetFdInfo(d.out)
go jsonmessage.DisplayJSONMessagesStream(in, d.out, outFd, isTerminal)
}
err := d.Client.PullImage(pullOpts, docker.AuthConfiguration{})
if err != nil {
return fmt.Errorf("failed to pull localkube image: %v", err)
}
return nil
}