forked from cloudfoundry-attic/bosh-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
job_resolver.go
35 lines (28 loc) · 927 Bytes
/
job_resolver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package release
import (
bosherr "github.com/cloudfoundry/bosh-init/internal/github.com/cloudfoundry/bosh-utils/errors"
birel "github.com/cloudfoundry/bosh-init/release"
bireljob "github.com/cloudfoundry/bosh-init/release/job"
)
type JobResolver interface {
Resolve(jobName, releaseName string) (bireljob.Job, error)
}
type resolver struct {
releaseManager birel.Manager
}
func NewJobResolver(releaseManager birel.Manager) JobResolver {
return &resolver{
releaseManager: releaseManager,
}
}
func (r *resolver) Resolve(jobName, releaseName string) (bireljob.Job, error) {
release, found := r.releaseManager.Find(releaseName)
if !found {
return bireljob.Job{}, bosherr.Errorf("Finding release '%s'", releaseName)
}
releaseJob, found := release.FindJobByName(jobName)
if !found {
return bireljob.Job{}, bosherr.Errorf("Finding job '%s' in release '%s'", jobName, releaseName)
}
return releaseJob, nil
}