コード例 #1
0
ファイル: docker.go プロジェクト: howbazaar/lingo
// Init the service.
func (d *Docker) Service() (Service, error) {
	log.Print("Docker Service called")

	// Ensure we have an image.
	c, err := d.getDockerClient()
	if err != nil {
		return nil, errors.Trace(err)
	}
	if !docker.HaveImage(c, d.Name) {

		// TODO(waigani) I think we should ask for user confirmation.
		fmt.Printf("\nno local image found for %s. Pulling new image from %s", d.Name, d.Registry)
		if err := d.Pull(false); err != nil {
			return nil, err
		}
	}

	return docker.NewService(d.Name)
}
コード例 #2
0
ファイル: docker.go プロジェクト: howbazaar/lingo
// Pull the image for this tenet from the given registry.
func (d *Docker) Pull(update bool) error {
	dClient, err := d.getDockerClient()
	if err != nil {
		return errors.Trace(err)
	}

	haveImage := docker.HaveImage(dClient, d.Name)

	fmt.Printf("\npulling %s ... ", d.Name)
	if haveImage && !update {
		fmt.Printf("%s has already been pulled. Use --update to update.\n", d.Name)
		return nil
	}

	if update || !haveImage {
		if err := docker.PullImage(dClient, d.Name, d.Registry, d.Tag); err != nil {
			return err
		}
	}
	fmt.Printf("done.\n")
	return nil
}