예제 #1
0
파일: resolver.go 프로젝트: aaithal/empire
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
0
파일: extractor.go 프로젝트: mhahn/empire
// 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
0
파일: extractor.go 프로젝트: mhahn/empire
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
0
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
0
파일: resolver.go 프로젝트: no2key/empire
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
}