예제 #1
0
파일: deployer.go 프로젝트: brianz/empire
// Deploy builds/determines the docker image to deploy, then deploys it with
// Empire.
func (d *EmpireDeployer) Deploy(ctx context.Context, event events.Deployment, w io.Writer) error {
	img, err := d.BuildImage(ctx, w, event)
	if err != nil {
		return err
	}

	// What we write to w should be plain text. `p` will get the jsonmessage
	// stream.
	p := dockerutil.DecodeJSONMessageStream(w)

	message := event.Deployment.Description
	if message == "" {
		message = fmt.Sprintf("GitHub deployment #%d of %s", event.Deployment.ID, event.Repository.FullName)
	}
	_, err = d.empire.Deploy(ctx, empire.DeployOpts{
		Image:   img,
		Output:  empire.NewDeploymentStream(p),
		User:    &empire.User{Name: event.Deployment.Creator.Login},
		Stream:  true,
		Message: message,
	})
	if err != nil {
		return err
	}

	return p.Err()
}
예제 #2
0
파일: deployer.go 프로젝트: is00hcw/empire
func (d *TugboatDeployer) Deploy(ctx context.Context, event events.Deployment, out io.Writer) error {
	opts := tugboat.NewDeployOptsFromEvent(event)

	// Perform the deployment, wrapped in Deploy. This will automatically
	// write hte logs to tugboat and update the deployment status when this
	// function returns.
	_, err := d.client.Deploy(ctx, opts, provider(func(ctx context.Context, _ *tugboat.Deployment, w io.Writer) error {
		// What we send to tugboat should be a plain text stream.
		p := dockerutil.DecodeJSONMessageStream(w)

		// Write logs to both tugboat as well as the writer we were
		// provided (probably stdout).
		w = io.MultiWriter(p, out)

		if err := d.deployer.Deploy(ctx, event, w); err != nil {
			return err
		}

		if err := p.Err(); err != nil {
			return err
		}

		return nil
	}))

	return err
}
예제 #3
0
// Deploy builds/determines the docker image to deploy, then deploys it with
// Empire.
func (d *EmpireDeployer) Deploy(ctx context.Context, event events.Deployment, w io.Writer) error {
	img, err := d.BuildImage(ctx, w, event)
	if err != nil {
		return err
	}

	// What we write to w should be plain text. `p` will get the jsonmessage
	// stream.
	p := dockerutil.DecodeJSONMessageStream(w)

	_, err = d.empire.Deploy(ctx, empire.DeployOpts{
		Image:  img,
		Output: p,
		User:   &empire.User{Name: event.Deployment.Creator.Login},
	})
	if err != nil {
		return err
	}

	return p.Err()
}