forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildpack.go
41 lines (32 loc) · 859 Bytes
/
buildpack.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
36
37
38
39
40
41
package requirements
import (
"code.cloudfoundry.org/cli/cf/api"
"code.cloudfoundry.org/cli/cf/models"
)
//go:generate counterfeiter . BuildpackRequirement
type BuildpackRequirement interface {
Requirement
GetBuildpack() models.Buildpack
}
type buildpackAPIRequirement struct {
name string
buildpackRepo api.BuildpackRepository
buildpack models.Buildpack
}
func NewBuildpackRequirement(name string, bR api.BuildpackRepository) (req *buildpackAPIRequirement) {
req = new(buildpackAPIRequirement)
req.name = name
req.buildpackRepo = bR
return
}
func (req *buildpackAPIRequirement) Execute() error {
var apiErr error
req.buildpack, apiErr = req.buildpackRepo.FindByName(req.name)
if apiErr != nil {
return apiErr
}
return nil
}
func (req *buildpackAPIRequirement) GetBuildpack() models.Buildpack {
return req.buildpack
}