@@ -21,52 +21,60 @@ type Downloader interface {
21
21
Download (url string , tmpDirPath string ) (string , error )
22
22
}
23
23
24
- func (actor Actor ) GetBuildpacks (labelSelector string ) ([]resources.Buildpack , Warnings , error ) {
25
- queries := []ccv3.Query {ccv3. Query { Key : ccv3 . OrderBy , Values : [] string { ccv3 . PositionOrder }} }
24
+ func (actor Actor ) GetBuildpacks (labelSelector string , lifecycle string ) ([]resources.Buildpack , Warnings , error ) {
25
+ queries := []ccv3.Query {}
26
26
if labelSelector != "" {
27
27
queries = append (queries , ccv3.Query {Key : ccv3 .LabelSelectorFilter , Values : []string {labelSelector }})
28
28
}
29
29
30
+ if lifecycle != "" {
31
+ queries = append (queries , ccv3.Query {Key : ccv3 .LifecycleFilter , Values : []string {lifecycle }})
32
+ }
33
+
30
34
buildpacks , warnings , err := actor .CloudControllerClient .GetBuildpacks (queries ... )
31
35
32
36
return buildpacks , Warnings (warnings ), err
33
37
}
34
38
35
- // GetBuildpackByNameAndStack returns a buildpack with the provided name and
36
- // stack . If `buildpackStack` is not specified, and there are multiple
39
+ // GetBuildpackByNameAndStackAndLifecycle returns a buildpack with the provided name, stack,
40
+ // and lifecycle . If `buildpackStack` is not specified, and there are multiple
37
41
// buildpacks with the same name, it will return the one with no stack, if
38
- // present.
39
- func (actor Actor ) GetBuildpackByNameAndStack (buildpackName string , buildpackStack string ) (resources.Buildpack , Warnings , error ) {
42
+ // present. If `buildpackLifecycle` is not specified and there are multiple buildpacks with
43
+ // the same name, it will return the one with the default_app_lifecycle, if present.
44
+ func (actor Actor ) GetBuildpackByNameAndStackAndLifecycle (buildpackName string , buildpackStack string , buildpackLifecycle string ) (resources.Buildpack , Warnings , error ) {
40
45
var (
41
46
buildpacks []resources.Buildpack
42
47
warnings ccv3.Warnings
43
48
err error
44
49
)
45
50
46
- if buildpackStack == "" {
47
- buildpacks , warnings , err = actor .CloudControllerClient .GetBuildpacks (ccv3.Query {
48
- Key : ccv3 .NameFilter ,
49
- Values : []string {buildpackName },
51
+ queries := []ccv3.Query {{
52
+ Key : ccv3 .NameFilter ,
53
+ Values : []string {buildpackName },
54
+ }}
55
+
56
+ if buildpackStack != "" {
57
+ queries = append (queries , ccv3.Query {
58
+ Key : ccv3 .StackFilter ,
59
+ Values : []string {buildpackStack },
50
60
})
51
- } else {
52
- buildpacks , warnings , err = actor .CloudControllerClient .GetBuildpacks (
53
- ccv3.Query {
54
- Key : ccv3 .NameFilter ,
55
- Values : []string {buildpackName },
56
- },
57
- ccv3.Query {
58
- Key : ccv3 .StackFilter ,
59
- Values : []string {buildpackStack },
60
- },
61
- )
62
61
}
63
62
63
+ if buildpackLifecycle != "" {
64
+ queries = append (queries , ccv3.Query {
65
+ Key : ccv3 .LifecycleFilter ,
66
+ Values : []string {buildpackLifecycle },
67
+ })
68
+ }
69
+
70
+ buildpacks , warnings , err = actor .CloudControllerClient .GetBuildpacks (queries ... )
71
+
64
72
if err != nil {
65
73
return resources.Buildpack {}, Warnings (warnings ), err
66
74
}
67
75
68
76
if len (buildpacks ) == 0 {
69
- return resources.Buildpack {}, Warnings (warnings ), actionerror.BuildpackNotFoundError {BuildpackName : buildpackName , StackName : buildpackStack }
77
+ return resources.Buildpack {}, Warnings (warnings ), actionerror.BuildpackNotFoundError {BuildpackName : buildpackName , StackName : buildpackStack , Lifecycle : buildpackLifecycle }
70
78
}
71
79
72
80
if len (buildpacks ) > 1 {
@@ -87,9 +95,9 @@ func (actor Actor) CreateBuildpack(buildpack resources.Buildpack) (resources.Bui
87
95
return buildpack , Warnings (warnings ), err
88
96
}
89
97
90
- func (actor Actor ) UpdateBuildpackByNameAndStack (buildpackName string , buildpackStack string , buildpack resources.Buildpack ) (resources.Buildpack , Warnings , error ) {
98
+ func (actor Actor ) UpdateBuildpackByNameAndStackAndLifecycle (buildpackName string , buildpackStack string , buildpackLifecycle string , buildpack resources.Buildpack ) (resources.Buildpack , Warnings , error ) {
91
99
var warnings Warnings
92
- foundBuildpack , getWarnings , err := actor .GetBuildpackByNameAndStack (buildpackName , buildpackStack )
100
+ foundBuildpack , getWarnings , err := actor .GetBuildpackByNameAndStackAndLifecycle (buildpackName , buildpackStack , buildpackLifecycle )
93
101
warnings = append (warnings , getWarnings ... )
94
102
95
103
if err != nil {
@@ -250,9 +258,9 @@ func Zipit(source, target, prefix string) error {
250
258
return err
251
259
}
252
260
253
- func (actor Actor ) DeleteBuildpackByNameAndStack (buildpackName string , buildpackStack string ) (Warnings , error ) {
261
+ func (actor Actor ) DeleteBuildpackByNameAndStackAndLifecycle (buildpackName string , buildpackStack string , buildpackLifecycle string ) (Warnings , error ) {
254
262
var allWarnings Warnings
255
- buildpack , getBuildpackWarnings , err := actor .GetBuildpackByNameAndStack (buildpackName , buildpackStack )
263
+ buildpack , getBuildpackWarnings , err := actor .GetBuildpackByNameAndStackAndLifecycle (buildpackName , buildpackStack , buildpackLifecycle )
256
264
allWarnings = append (allWarnings , getBuildpackWarnings ... )
257
265
if err != nil {
258
266
return allWarnings , err
0 commit comments