forked from cloudfoundry/cli
/
setup_all_resources_for_push_plan.go
47 lines (39 loc) · 1.19 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
package v7pushaction
import (
"code.cloudfoundry.org/cli/actor/sharedaction"
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant"
"code.cloudfoundry.org/cli/util/manifestparser"
"errors"
"os"
)
func (actor Actor) SetupAllResourcesForPushPlan(pushPlan PushPlan, overrides FlagOverrides, manifestApp manifestparser.Application) (PushPlan, error) {
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
}