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 }
// 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(), }, }) }
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, }, }) }
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 }
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 }