1package release
2
3import (
4	birel "github.com/cloudfoundry/bosh-cli/release"
5	bosherr "github.com/cloudfoundry/bosh-utils/errors"
6)
7
8const (
9	ReleaseBinaryName = "bin/cpi"
10)
11
12type Validator struct {
13}
14
15func NewValidator() Validator {
16	return Validator{}
17}
18
19func (v Validator) Validate(release birel.Release, cpiReleaseJobName string) error {
20	job, ok := release.FindJobByName(cpiReleaseJobName)
21	if !ok {
22		return bosherr.Errorf("CPI release must contain specified job '%s'", cpiReleaseJobName)
23	}
24
25	_, ok = job.FindTemplateByValue(ReleaseBinaryName)
26	if !ok {
27		return bosherr.Errorf("Specified CPI release job '%s' must contain a template that renders to target '%s'", cpiReleaseJobName, ReleaseBinaryName)
28	}
29
30	return nil
31}
32