本文整理匯總了Golang中github.com/remind101/empire/pkg/image.Image類的典型用法代碼示例。如果您正苦於以下問題:Golang Image類的具體用法?Golang Image怎麽用?Golang Image使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Image類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Resolve
func (r *dockerResolver) Resolve(ctx context.Context, img image.Image, out chan Event) (image.Image, error) {
pr, pw := io.Pipe()
errCh := make(chan error, 1)
go func() {
defer pw.Close()
errCh <- r.pullImage(ctx, img, pw)
}()
dec := json.NewDecoder(pr)
for {
var e DockerEvent
if err := dec.Decode(&e); err == io.EOF {
break
} else if err != nil {
return img, err
}
out <- &e
}
// Wait for pullImage to finish
if err := <-errCh; err != nil {
return img, err
}
i, err := r.client.InspectImage(img.String())
if err != nil {
return img, err
}
return image.Image{
Repository: img.Repository,
Tag: i.ID,
}, nil
}
示例2: createContainer
// createContainer creates a new docker container for the given docker image.
func (e *fileExtractor) createContainer(ctx context.Context, img image.Image) (*docker.Container, error) {
return e.client.CreateContainer(ctx, docker.CreateContainerOptions{
Config: &docker.Config{
Image: img.String(),
},
})
}
示例3: Extract
func (e *cmdExtractor) Extract(ctx context.Context, img image.Image, _ io.Writer) ([]byte, error) {
i, err := e.client.InspectImage(img.String())
if err != nil {
return nil, err
}
return procfile.Marshal(procfile.ExtendedProcfile{
"web": procfile.Process{
Command: i.Config.Cmd,
},
})
}
示例4: Extract
func (e *CMDExtractor) Extract(img image.Image) (Procfile, error) {
pm := make(Procfile)
i, err := e.client.InspectImage(img.String())
if err != nil {
return pm, err
}
pm["web"] = strings.Join(i.Config.Cmd, " ")
return pm, nil
}
示例5: Resolve
func (r *dockerResolver) Resolve(ctx context.Context, img image.Image, out io.Writer) (image.Image, error) {
if err := r.pullImage(ctx, img, out); err != nil {
return img, err
}
i, err := r.client.InspectImage(img.String())
if err != nil {
return img, err
}
return image.Image{
Repository: img.Repository,
Tag: i.ID,
}, nil
}