예제 #1
0
// Configure will analyze the given remote identifier and define the required parameters for
// Compose and Publish modules.
func (c *Configuration) Configure(remote string) error {

	r, err := parser.Parse(remote)
	if err != nil {
		return err
	}

	c.Compose.Name = r.Name()
	c.Publish.Hostname = r.Registry()
	return nil
}
예제 #2
0
파일: run.go 프로젝트: crowley-io/pack
// See Docker interface
func (d docker) Run(option RunOptions, stream LogStream) (int, error) {

	r, err := parser.Parse(option.Image)
	if err != nil {
		return 0, err
	}

	err = d.client.PullImage(pullImageOptions(r.Remote(), stream), pullAuthConfiguration(option))
	if err != nil {
		return 0, err
	}

	e, err := d.client.CreateContainer(createContainerOptions(option))

	if err != nil {
		return 0, err
	}

	id := e.ID

	if err = d.client.StartContainer(id, nil); err != nil {
		return 0, err
	}

	err = d.Logs(id, stream)

	if err != nil {
		fmt.Fprint(stream.Err, err)
	}

	exit, err := d.client.WaitContainer(id)

	if err != nil {
		return 0, err
	}

	if err = d.client.RemoveContainer(removeContainerOptions(id)); err != nil {
		return 0, err
	}

	return exit, nil

}
예제 #3
0
파일: publish.go 프로젝트: crowley-io/pack
// Publish push the docker image into the docker registy.
func Publish(client docker.Docker, stream docker.LogStream, configuration *configuration.Configuration) error {

	if err := configuration.Validate(); err != nil {
		return err
	}

	reference, err := parser.Parse(remote(configuration))

	if err != nil {
		return err
	}

	tagOpts := docker.TagOptions{
		Name:       reference.Name(),
		Repository: reference.Repository(),
		Tag:        reference.Tag(),
	}

	pushOpts := docker.PushOptions{
		Name:       reference.Name(),
		Repository: reference.Repository(),
		Registry:   reference.Registry(),
		Tag:        reference.Tag(),
	}

	if err = client.Tag(tagOpts); err != nil {
		return err
	}

	err = client.Push(pushOpts, stream)

	// Remove registry tag
	if err2 := client.RemoveImage(reference.Remote()); err2 != nil && err == nil {
		err = err2
	}

	return err
}