-
Notifications
You must be signed in to change notification settings - Fork 929
/
setup_application_for_push_plan.go
42 lines (32 loc) · 1.19 KB
/
setup_application_for_push_plan.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
42
package v7pushaction
import (
"code.cloudfoundry.org/cli/actor/v7action"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
"code.cloudfoundry.org/cli/util/manifestparser"
)
func SetupApplicationForPushPlan(pushPlan PushPlan, overrides FlagOverrides, manifestApp manifestparser.Application) (PushPlan, error) {
application := v7action.Application{Name: manifestApp.Name}
var applicationNeedsUpdate bool
if buildpacksPresent(overrides) {
application.LifecycleType = constant.AppLifecycleTypeBuildpack
application.LifecycleBuildpacks = overrides.Buildpacks
applicationNeedsUpdate = true
}
if stacksPresent(overrides) {
application.StackName = overrides.Stack
application.LifecycleType = constant.AppLifecycleTypeBuildpack
applicationNeedsUpdate = true
}
if overrides.DockerImage != "" || manifestApp.Docker != nil {
application.LifecycleType = constant.AppLifecycleTypeDocker
}
pushPlan.Application = application
pushPlan.ApplicationNeedsUpdate = applicationNeedsUpdate
return pushPlan, nil
}
func buildpacksPresent(overrides FlagOverrides) bool {
return len(overrides.Buildpacks) > 0
}
func stacksPresent(overrides FlagOverrides) bool {
return overrides.Stack != ""
}