예제 #1
0
파일: builder.go 프로젝트: brianz/empire
// ImageFromTemplate returns an ImageBuilder that will execute a template to
// determine what docker image should be deployed. Note that this doesn't not
// actually perform any "build".
func ImageFromTemplate(t *template.Template) ImageBuilder {
	return ImageBuilderFunc(func(ctx context.Context, _ io.Writer, event events.Deployment) (image.Image, error) {
		buf := new(bytes.Buffer)
		if err := t.Execute(buf, event); err != nil {
			return image.Image{}, err
		}

		return image.Decode(buf.String())
	})
}
예제 #2
0
파일: builder.go 프로젝트: brianz/empire
func (c *ConveyorImageBuilder) BuildImage(ctx context.Context, w io.Writer, event events.Deployment) (image.Image, error) {
	a, err := c.client.Build(w, conveyor.BuildCreateOpts{
		Repository: event.Repository.FullName,
		Sha:        &event.Deployment.Sha,
	})
	if err != nil {
		return image.Image{}, err
	}

	return image.Decode(a.Image)
}
예제 #3
0
파일: github.go 프로젝트: frewsxcv/empire
// Image returns an image.Image for the given deployment.
func Image(t string, d events.Deployment) (image.Image, error) {
	if t == "" {
		t = DefaultTemplate
	}

	tmpl, err := template.New("image").Parse(t)
	if err != nil {
		return image.Image{}, err
	}

	buf := new(bytes.Buffer)
	if err := tmpl.Execute(buf, d); err != nil {
		return image.Image{}, err
	}

	return image.Decode(buf.String())
}