@@ -170,6 +170,12 @@ type BaseState struct {
170
170
StepDetail string `json:",omitempty"`
171
171
}
172
172
173
+ // ScheduledStopStatus holds string representation of scheduledStopDuration
174
+ type ScheduledStopStatus struct {
175
+ InitiatedTime string `json:",omitempty"`
176
+ ScheduledTime string `json:",omitempty"`
177
+ }
178
+
173
179
const (
174
180
minikubeNotRunningStatusFlag = 1 << 0
175
181
clusterNotRunningStatusFlag = 1 << 1
@@ -187,6 +193,12 @@ type: Worker
187
193
host: {{.Host}}
188
194
kubelet: {{.Kubelet}}
189
195
196
+ `
197
+
198
+ scheduledStopStatusFormat = `type: ScheduledDuration
199
+ initiatedTime: {{.InitiatedTime}}
200
+ scheduledTime: {{.ScheduledTime}}
201
+
190
202
`
191
203
)
192
204
@@ -256,6 +268,11 @@ func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *con
256
268
exit .Error (reason .InternalStatusText , "status text failure" , err )
257
269
}
258
270
}
271
+ if cc .ScheduledStop != nil {
272
+ if err := scheduledStopStatusText (cc .ScheduledStop , os .Stdout ); err != nil {
273
+ exit .Error (reason .InternalStatusText , "status text failure" , err )
274
+ }
275
+ }
259
276
case "json" :
260
277
// Layout is currently only supported for JSON mode
261
278
if layout == "cluster" {
@@ -267,6 +284,11 @@ func writeStatusesAtInterval(duration time.Duration, api libmachine.API, cc *con
267
284
exit .Error (reason .InternalStatusJSON , "status json failure" , err )
268
285
}
269
286
}
287
+ if cc .ScheduledStop != nil {
288
+ if err := scheduledStopStatusJSON (cc .ScheduledStop , os .Stdout ); err != nil {
289
+ exit .Error (reason .InternalStatusJSON , "scheduledstop status json failure" , err )
290
+ }
291
+ }
270
292
default :
271
293
exit .Message (reason .Usage , fmt .Sprintf ("invalid output format: %s. Valid values: 'text', 'json'" , output ))
272
294
}
@@ -444,6 +466,39 @@ func statusJSON(st []*Status, w io.Writer) error {
444
466
return err
445
467
}
446
468
469
+ func scheduledStopStatusText (sd * config.ScheduledStopConfig , w io.Writer ) error {
470
+ var scheduledStopStatus ScheduledStopStatus
471
+ if sd .InitiationTime == 0 {
472
+ scheduledStopStatus .InitiatedTime = "-"
473
+ } else {
474
+ scheduledStopStatus .InitiatedTime = time .Unix (sd .InitiationTime , 0 ).String ()
475
+ }
476
+ if sd .Duration == 0 {
477
+ scheduledStopStatus .ScheduledTime = "-"
478
+ } else {
479
+ stopAt := time .Now ().Add (sd .Duration ).Unix ()
480
+ scheduledStopStatus .ScheduledTime = time .Unix (stopAt , 0 ).String ()
481
+ }
482
+ tmpl , err := template .New ("scheduled-stop-status" ).Parse (scheduledStopStatusFormat )
483
+ if err != nil {
484
+ return err
485
+ }
486
+ if err := tmpl .Execute (w , scheduledStopStatus ); err != nil {
487
+ return err
488
+ }
489
+ return nil
490
+ }
491
+
492
+ func scheduledStopStatusJSON (sd * config.ScheduledStopConfig , w io.Writer ) error {
493
+ var js []byte
494
+ js , err := json .Marshal (sd )
495
+ if err != nil {
496
+ return err
497
+ }
498
+ _ , err = w .Write (js )
499
+ return err
500
+ }
501
+
447
502
// readEventLog reads cloudevent logs from $MINIKUBE_HOME/profiles/<name>/events.json
448
503
func readEventLog (name string ) ([]cloudevents.Event , time.Time , error ) {
449
504
path := localpath .EventLog (name )
0 commit comments