forked from cloudfoundry-community/cloudfoundry-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.go
63 lines (53 loc) · 2.18 KB
/
manifest.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
52
53
54
55
56
57
58
59
60
61
62
63
package v2action
import (
"code.cloudfoundry.org/cli/api/cloudcontroller/ccv2/constant"
"code.cloudfoundry.org/cli/util/manifest"
)
func (actor Actor) CreateApplicationManifestByNameAndSpace(appName string, spaceGUID string, pathToFile string) (Warnings, error) {
var allWarnings Warnings
applicationSummary, appSummaryWarnings, err := actor.GetApplicationSummaryByNameAndSpace(appName, spaceGUID)
allWarnings = append(allWarnings, appSummaryWarnings...)
if err != nil {
return allWarnings, err
}
serviceInstances, serviceWarnings, err := actor.GetServiceInstancesByApplication(applicationSummary.GUID)
allWarnings = append(allWarnings, serviceWarnings...)
if err != nil {
return allWarnings, err
}
var routes []string
for _, route := range applicationSummary.Routes {
routes = append(routes, route.String())
}
var services []string
for _, serviceInstace := range serviceInstances {
services = append(services, serviceInstace.Name)
}
manifestApp := manifest.Application{
Buildpack: applicationSummary.Buildpack,
Command: applicationSummary.Command,
DiskQuota: applicationSummary.DiskQuota,
DockerImage: applicationSummary.DockerImage,
DockerUsername: applicationSummary.DockerCredentials.Username,
EnvironmentVariables: applicationSummary.EnvironmentVariables,
HealthCheckTimeout: applicationSummary.HealthCheckTimeout,
Instances: applicationSummary.Instances,
Memory: applicationSummary.Memory,
Name: applicationSummary.Name,
Routes: routes,
Services: services,
StackName: applicationSummary.Stack.Name,
}
if len(routes) < 1 {
manifestApp.NoRoute = true
}
if applicationSummary.HealthCheckType != constant.ApplicationHealthCheckPort {
manifestApp.HealthCheckType = string(applicationSummary.HealthCheckType)
if applicationSummary.HealthCheckType == constant.ApplicationHealthCheckHTTP &&
applicationSummary.HealthCheckHTTPEndpoint != "/" {
manifestApp.HealthCheckHTTPEndpoint = applicationSummary.HealthCheckHTTPEndpoint
}
}
err = manifest.WriteApplicationManifest(manifestApp, pathToFile)
return allWarnings, err
}