@@ -27,6 +27,7 @@ import (
27
27
"encoding/json"
28
28
"fmt"
29
29
"net/url"
30
+ "strconv"
30
31
"time"
31
32
32
33
batchv1beta1 "k8s.io/api/batch/v1beta1"
@@ -605,9 +606,9 @@ func (u *URL3) MarshalText() (text []byte, err error) {
605
606
return u .MarshalBinary ()
606
607
}
607
608
608
- // URL4 is an alias of [net/url.URL]. It implements [encoding.TextMarshaler] so
609
- // that it can be used in K8s CRDs such that the CRD resource will have the URL
610
- // but operator code can can work with the URL struct.
609
+ // URL4 is newtype around [net/url.URL]. It implements [encoding.TextMarshaler]
610
+ // so that it can be used in K8s CRDs such that the CRD resource will have the
611
+ // URL but operator code can can work with the URL struct.
611
612
type URL4 url.URL
612
613
613
614
var _ encoding.TextMarshaler = (* URL4 )(nil )
@@ -617,6 +618,28 @@ func (u *URL4) MarshalText() (text []byte, err error) {
617
618
return (* url .URL )(u ).MarshalBinary ()
618
619
}
619
620
621
+ // +kubebuilder:validation:Type=integer
622
+ // +kubebuilder:validation:Format=int64
623
+ // Time2 is a newtype around [metav1.Time].
624
+ // It implements both [encoding.TextMarshaler] and [json.Marshaler].
625
+ // The latter is authoritative for the CRD generation.
626
+ type Time2 time.Time
627
+
628
+ var _ interface {
629
+ encoding.TextMarshaler
630
+ json.Marshaler
631
+ } = (* Time2 )(nil )
632
+
633
+ // MarshalText implements [encoding.TextMarshaler].
634
+ func (t * Time2 ) MarshalText () (text []byte , err error ) {
635
+ return []byte ((* time .Time )(t ).String ()), nil
636
+ }
637
+
638
+ // MarshalJSON implements [json.Marshaler].
639
+ func (t * Time2 ) MarshalJSON () ([]byte , error ) {
640
+ return strconv .AppendInt (nil , (* time .Time )(t ).UnixMilli (), 10 ), nil
641
+ }
642
+
620
643
// Duration has a custom Marshaler but no markers.
621
644
// We want the CRD generation to infer type information
622
645
// from the go types and ignore the presense of the Marshaler.
@@ -667,6 +690,10 @@ type CronJobStatus struct {
667
690
// +optional
668
691
LastScheduleTime * metav1.Time `json:"lastScheduleTime,omitempty"`
669
692
693
+ // Information when was the last time the job was successfully scheduled.
694
+ // +optional
695
+ LastScheduleTime2 Time2 `json:"lastScheduleTime2,omitempty"`
696
+
670
697
// Information about the last time the job was successfully scheduled,
671
698
// with microsecond precision.
672
699
// +optional
0 commit comments