github.com/loggregator/cli@v6.33.1-0.20180224010324-82334f081791+incompatible/cf/requirements/buildpack.go (about) 1 package requirements 2 3 import ( 4 "code.cloudfoundry.org/cli/cf/api" 5 "code.cloudfoundry.org/cli/cf/models" 6 ) 7 8 //go:generate counterfeiter . BuildpackRequirement 9 10 type BuildpackRequirement interface { 11 Requirement 12 GetBuildpack() models.Buildpack 13 } 14 15 type buildpackAPIRequirement struct { 16 name string 17 buildpackRepo api.BuildpackRepository 18 buildpack models.Buildpack 19 } 20 21 func NewBuildpackRequirement(name string, bR api.BuildpackRepository) (req *buildpackAPIRequirement) { 22 req = new(buildpackAPIRequirement) 23 req.name = name 24 req.buildpackRepo = bR 25 return 26 } 27 28 func (req *buildpackAPIRequirement) Execute() error { 29 var apiErr error 30 req.buildpack, apiErr = req.buildpackRepo.FindByName(req.name) 31 32 if apiErr != nil { 33 return apiErr 34 } 35 36 return nil 37 } 38 39 func (req *buildpackAPIRequirement) GetBuildpack() models.Buildpack { 40 return req.buildpack 41 }