Skip to content

Commit f5c5537

Browse files
committed
pkg: add CREATED to app/comp/vmspec
1 parent 291e423 commit f5c5537

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

pkg/handlers/print.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func PrintVMsFromController(vms []v1.VirtualMachine) {
178178
// PrintComponents prints components returned by the controller DB query.
179179
func PrintComponents(comps []v1.Component) {
180180
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
181-
fmt.Fprintln(w, "COMPONENT\tAPPLICATION\tREPLICAS\tVM SPEC\tSTATE\tOBSERVED REPLICAS\tLAST CHECKED")
181+
fmt.Fprintln(w, "COMPONENT\tAPPLICATION\tREPLICAS\tVM SPEC\tSTATE\tOBSERVED REPLICAS\tLAST CHECKED\tCREATED")
182182

183183
for _, c := range comps {
184184
replicas := c.Spec.Replicas
@@ -190,15 +190,19 @@ func PrintComponents(comps []v1.Component) {
190190
if !c.Status.LastChecked.IsZero() {
191191
last = c.Status.LastChecked.Format(time.RFC3339)
192192
}
193-
fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%d\t%s\n", c.Metadata.Name, appNames, replicas, vmSpec, state, observed, last)
193+
created := ""
194+
if !c.CreatedAt.IsZero() {
195+
created = c.CreatedAt.Format(time.RFC3339)
196+
}
197+
fmt.Fprintf(w, "%s\t%s\t%d\t%s\t%s\t%d\t%s\t%s\n", c.Metadata.Name, appNames, replicas, vmSpec, state, observed, last, created)
194198
}
195199
w.Flush()
196200
}
197201

198202
// PrintVMSpecs prints VirtualMachineSpecResource entries in a compact table.
199203
func PrintVMSpecs(specs []v1.VirtualMachineSpecResource) {
200204
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
201-
fmt.Fprintln(w, "VM SPEC\tTEMPLATE\tSERVICE OFFERING\tNETWORKS\tVOLUMES")
205+
fmt.Fprintln(w, "VM SPEC\tTEMPLATE\tSERVICE OFFERING\tNETWORKS\tVOLUMES\tCREATED")
202206
for _, s := range specs {
203207
tmpl := s.Spec.Template
204208
so := s.Spec.ServiceOffering
@@ -217,15 +221,19 @@ func PrintVMSpecs(specs []v1.VirtualMachineSpecResource) {
217221
}
218222
}
219223
}
220-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\n", s.Metadata.Name, tmpl, so, nets, volCount)
224+
created := ""
225+
if !s.CreatedAt.IsZero() {
226+
created = s.CreatedAt.Format(time.RFC3339)
227+
}
228+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%d\t%s\n", s.Metadata.Name, tmpl, so, nets, volCount, created)
221229
}
222230
w.Flush()
223231
}
224232

225233
// PrintApplications prints applications returned by the controller DB query.
226234
func PrintApplications(apps []v1.Application) {
227235
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
228-
fmt.Fprintln(w, "APPLICATION\tCOMPONENTS\tSTATE\tREADY\tLAST CHECKED")
236+
fmt.Fprintln(w, "APPLICATION\tCOMPONENTS\tSTATE\tREADY\tLAST CHECKED\tCREATED")
229237
for _, a := range apps {
230238
compNames := ""
231239
if len(a.Spec.Components) > 0 {
@@ -238,7 +246,11 @@ func PrintApplications(apps []v1.Application) {
238246
if !a.Status.LastChecked.IsZero() {
239247
last = a.Status.LastChecked.Format(time.RFC3339)
240248
}
241-
fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\n", a.Metadata.Name, compNames, a.Status.ObservedState, a.Status.Ready, last)
249+
created := ""
250+
if !a.CreatedAt.IsZero() {
251+
created = a.CreatedAt.Format(time.RFC3339)
252+
}
253+
fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\t%s\n", a.Metadata.Name, compNames, a.Status.ObservedState, a.Status.Ready, last, created)
242254
}
243255
w.Flush()
244256
}

0 commit comments

Comments
 (0)