Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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 {
		// Write logs to both tugboat as well as the writer we were
		// provided (probably stdout).
		w = io.MultiWriter(w, out)

		return d.deployer.Deploy(ctx, event, w)
	}))

	return err
}
Exemplo n.º 3
0
func (d *tugboatDeployer) Deploy(ctx context.Context, p events.Deployment, out io.Writer) error {
	opts := tugboat.NewDeployOptsFromEvent(p)

	// 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 {
		// Write logs to both tugboat as well as the writer we were
		// provided (probably stdout).
		w = io.MultiWriter(w, out)

		if err := d.deployer.Deploy(ctx, p, w); err != nil {
			// If we got a deployment error, write the error to
			// tugboat and return tugboat.ErrFailed to indicate the
			// failure.
			io.WriteString(w, err.Error())
			return tugboat.ErrFailed
		}

		return nil
	}))

	return err
}