forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_all_resources_for_push_plan.go
51 lines (41 loc) · 1.17 KB
/
setup_all_resources_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
43
44
45
46
47
48
49
50
51
package v7pushaction
import (
"errors"
"os"
"code.cloudfoundry.org/cli/actor/sharedaction"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
)
func (actor Actor) SetupAllResourcesForPushPlan(pushPlan PushPlan, overrides FlagOverrides) (PushPlan, error) {
if pushPlan.DropletPath != "" {
return pushPlan, nil
}
if pushPlan.Application.LifecycleType == constant.AppLifecycleTypeDocker {
return pushPlan, nil
}
path := pushPlan.BitsPath
if path == "" {
return PushPlan{}, errors.New("developer error: Bits Path needs to be set prior to generating app resources")
}
info, err := os.Stat(path)
if err != nil {
return PushPlan{}, err
}
var archive bool
var resources []sharedaction.Resource
if info.IsDir() {
resources, err = actor.SharedActor.GatherDirectoryResources(path)
} else {
archive = true
resources, err = actor.SharedActor.GatherArchiveResources(path)
}
if err != nil {
return PushPlan{}, err
}
var v3Resources []sharedaction.V3Resource
for _, resource := range resources {
v3Resources = append(v3Resources, resource.ToV3Resource())
}
pushPlan.Archive = archive
pushPlan.AllResources = v3Resources
return pushPlan, nil
}