-
Notifications
You must be signed in to change notification settings - Fork 929
/
application.go
136 lines (127 loc) · 2.97 KB
/
application.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package models
import (
"reflect"
"strings"
)
type Application struct {
ApplicationFields
Stack Stack
Routes []RouteSummary
}
func (model Application) ToParams() (params AppParams) {
state := strings.ToUpper(model.State)
params = AppParams{
Guid: &model.Guid,
Name: &model.Name,
BuildpackUrl: &model.BuildpackUrl,
Command: &model.Command,
DiskQuota: &model.DiskQuota,
InstanceCount: &model.InstanceCount,
Memory: &model.Memory,
State: &state,
StackGuid: &model.Stack.Guid,
SpaceGuid: &model.SpaceGuid,
EnvironmentVars: &model.EnvironmentVars,
}
return
}
type AppSummary struct {
ApplicationFields
RouteSummaries []RouteSummary
}
type ApplicationFields struct {
Guid string
Name string
BuildpackUrl string
Command string
DiskQuota uint64 // in Megabytes
EnvironmentVars map[string]string
InstanceCount int
Memory uint64 // in Megabytes
RunningInstances int
State string
SpaceGuid string
}
type AppParams struct {
BuildpackUrl *string
Command *string
DiskQuota *uint64
Domain *string
EnvironmentVars *map[string]string
Guid *string
HealthCheckTimeout *int
Host *string
InstanceCount *int
Memory *uint64
Name *string
NoRoute *bool
Path *string
RunningInstances *int
Services *[]string
SpaceGuid *string
StackGuid *string
StackName *string
State *string
}
func (app *AppParams) Merge(other *AppParams) {
if other.BuildpackUrl != nil {
app.BuildpackUrl = other.BuildpackUrl
}
if other.Command != nil {
app.Command = other.Command
}
if other.DiskQuota != nil {
app.DiskQuota = other.DiskQuota
}
if other.Domain != nil {
app.Domain = other.Domain
}
if other.EnvironmentVars != nil {
app.EnvironmentVars = other.EnvironmentVars
}
if other.Guid != nil {
app.Guid = other.Guid
}
if other.HealthCheckTimeout != nil {
app.HealthCheckTimeout = other.HealthCheckTimeout
}
if other.Host != nil {
app.Host = other.Host
}
if other.InstanceCount != nil {
app.InstanceCount = other.InstanceCount
}
if other.Memory != nil {
app.Memory = other.Memory
}
if other.Name != nil {
app.Name = other.Name
}
if other.NoRoute != nil {
app.NoRoute = other.NoRoute
}
if other.Path != nil {
app.Path = other.Path
}
if other.RunningInstances != nil {
app.RunningInstances = other.RunningInstances
}
if other.Services != nil {
app.Services = other.Services
}
if other.SpaceGuid != nil {
app.SpaceGuid = other.SpaceGuid
}
if other.StackGuid != nil {
app.StackGuid = other.StackGuid
}
if other.StackName != nil {
app.StackName = other.StackName
}
if other.State != nil {
app.State = other.State
}
}
func (app *AppParams) Equals(otherParams *AppParams) bool {
return reflect.DeepEqual(*app, *otherParams)
}