1
1
package models
2
2
3
+ import "bytes"
4
+
3
5
// SummaryReporter -
4
6
type SummaryReporter interface {
5
7
OrgReports () []OrgReporter
@@ -8,8 +10,8 @@ type SummaryReporter interface {
8
10
9
11
// SummaryReport holds an aggregated view of multiple OrgReports
10
12
type SummaryReport struct {
11
- orgsRef []Org
12
13
orgReportsRef []OrgReporter
14
+ orgsRef []Org
13
15
}
14
16
15
17
// NewSummaryReport -
@@ -25,8 +27,18 @@ func NewSummaryReport(orgs []Org) *SummaryReport {
25
27
}
26
28
}
27
29
30
+ // OrgReports -
31
+ func (s * SummaryReport ) OrgReports () []OrgReporter {
32
+ return s .orgReportsRef
33
+ }
34
+
35
+ // Name -
28
36
func (s * SummaryReport ) Name () string {
29
- return "nil"
37
+ var name bytes.Buffer
38
+ for _ , org := range s .orgReportsRef {
39
+ name .WriteString (org .Name ())
40
+ }
41
+ return name .String ()
30
42
}
31
43
32
44
// ServicesSuiteForPivotalPlatformCount returns the number of service instances
@@ -35,11 +47,11 @@ func (s *SummaryReport) Name() string {
35
47
// see: https://network.pivotal.io/products/pcf-services
36
48
// (I know right? It's an intense function name)
37
49
func (s * SummaryReport ) ServicesSuiteForPivotalPlatformCount () int {
38
- return 0
39
- }
40
-
41
- func ( s * SummaryReport ) OrgReports () [] OrgReporter {
42
- return s . orgReportsRef
50
+ count := 0
51
+ for _ , report := range s . orgReportsRef {
52
+ count += report . ServicesSuiteForPivotalPlatformCount ()
53
+ }
54
+ return count
43
55
}
44
56
45
57
// AppInstancesCount returns the count of declared canonical app instances
@@ -53,7 +65,11 @@ func (s *SummaryReport) OrgReports() []OrgReporter {
53
65
//
54
66
// then you'd have "5 app instances"
55
67
func (s * SummaryReport ) AppInstancesCount () int {
56
- return 0
68
+ count := 0
69
+ for _ , report := range s .orgReportsRef {
70
+ count += report .AppInstancesCount ()
71
+ }
72
+ return count
57
73
}
58
74
59
75
// AppsCount returns the count of unique canonical app guids
@@ -67,31 +83,53 @@ func (s *SummaryReport) AppInstancesCount() int {
67
83
//
68
84
// then you'd have "3 unique apps"
69
85
func (s * SummaryReport ) AppsCount () int {
70
- return 0
86
+ count := 0
87
+ for _ , report := range s .orgReportsRef {
88
+ count += report .AppsCount ()
89
+ }
90
+ return count
71
91
}
72
92
73
93
// BillableAppInstancesCount returns the count of "billable" AIs
74
94
//
75
95
// This includes anything which Pivotal deems "billable" as an AI, even if CF
76
96
// considers it a service; e.g., SCS instances (config server, service registry, etc.)
77
97
func (s * SummaryReport ) BillableAppInstancesCount () int {
78
- return 0
98
+ count := 0
99
+ for _ , report := range s .orgReportsRef {
100
+ count += report .BillableAppInstancesCount ()
101
+ }
102
+ return count
79
103
}
80
104
81
105
// BillableServicesCount returns the count of "billable" SIs
82
106
//
83
107
// This includes anything which Pivotal deems "billable" as an SI; this might mean
84
108
// subtracting certain services (like SCS) from the count of `cf services`
85
109
func (s * SummaryReport ) BillableServicesCount () int {
86
- return 0
110
+ count := 0
111
+ for _ , report := range s .orgReportsRef {
112
+ count += report .BillableServicesCount ()
113
+ }
114
+ return count
87
115
}
88
116
117
+ // MemoryQuota -
89
118
func (s * SummaryReport ) MemoryQuota () int {
90
- return 0
119
+ count := 0
120
+ for _ , report := range s .orgReportsRef {
121
+ count += report .MemoryQuota ()
122
+ }
123
+ return count
91
124
}
92
125
126
+ // MemoryUsage -
93
127
func (s * SummaryReport ) MemoryUsage () int {
94
- return 0
128
+ count := 0
129
+ for _ , report := range s .orgReportsRef {
130
+ count += report .MemoryUsage ()
131
+ }
132
+ return count
95
133
}
96
134
97
135
// RunningAppInstancesCount returns the count of declared canonical app instances
@@ -105,7 +143,11 @@ func (s *SummaryReport) MemoryUsage() int {
105
143
//
106
144
// then you'd have "4 running app instances"
107
145
func (s * SummaryReport ) RunningAppInstancesCount () int {
108
- return 0
146
+ count := 0
147
+ for _ , report := range s .orgReportsRef {
148
+ count += report .RunningAppInstancesCount ()
149
+ }
150
+ return count
109
151
}
110
152
111
153
// RunningAppsCount returns the count of unique canonical app
@@ -119,7 +161,11 @@ func (s *SummaryReport) RunningAppInstancesCount() int {
119
161
//
120
162
// then you'd have "2 running apps"
121
163
func (s * SummaryReport ) RunningAppsCount () int {
122
- return 0
164
+ count := 0
165
+ for _ , report := range s .orgReportsRef {
166
+ count += report .RunningAppsCount ()
167
+ }
168
+ return count
123
169
}
124
170
125
171
// ServicesCount returns total count of registered services
@@ -129,21 +175,40 @@ func (s *SummaryReport) RunningAppsCount() int {
129
175
// those aren't considered in this result. This only counts services registered which
130
176
// show up in `cf services`
131
177
func (s * SummaryReport ) ServicesCount () int {
132
- return 0
178
+ count := 0
179
+ for _ , report := range s .orgReportsRef {
180
+ count += report .ServicesCount ()
181
+ }
182
+ return count
133
183
}
134
184
135
185
// SpringCloudServicesCount returns the number of service instances
136
186
// from "spring cloud services" tile, e.g. config-server/service-registry/circuit-breaker/etc.
137
187
//
138
188
// see: https://network.pivotal.io/products/p-spring-cloud-services/
139
189
func (s * SummaryReport ) SpringCloudServicesCount () int {
140
- return 0
190
+ count := 0
191
+ for _ , report := range s .orgReportsRef {
192
+ count += report .SpringCloudServicesCount ()
193
+ }
194
+ return count
141
195
}
142
196
197
+ // StoppedAppInstancesCount -
143
198
func (s * SummaryReport ) StoppedAppInstancesCount () int {
144
- return 0
199
+ count := 0
200
+ for _ , report := range s .orgReportsRef {
201
+ count += report .StoppedAppInstancesCount ()
202
+ }
203
+ return count
145
204
}
146
205
206
+ // StoppedAppsCount -
147
207
func (s * SummaryReport ) StoppedAppsCount () int {
148
- return 0
208
+ count := 0
209
+ for _ , report := range s .orgReportsRef {
210
+ count += report .StoppedAppsCount ()
211
+ }
212
+ return count
213
+
149
214
}
0 commit comments