@@ -27,6 +27,7 @@ import (
2727 "encoding/json"
2828 "fmt"
2929 "net/url"
30+ "strconv"
3031 "time"
3132
3233 batchv1beta1 "k8s.io/api/batch/v1beta1"
@@ -605,9 +606,9 @@ func (u *URL3) MarshalText() (text []byte, err error) {
605606 return u .MarshalBinary ()
606607}
607608
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.
611612type URL4 url.URL
612613
613614var _ encoding.TextMarshaler = (* URL4 )(nil )
@@ -617,6 +618,28 @@ func (u *URL4) MarshalText() (text []byte, err error) {
617618 return (* url .URL )(u ).MarshalBinary ()
618619}
619620
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+
620643// Duration has a custom Marshaler but no markers.
621644// We want the CRD generation to infer type information
622645// from the go types and ignore the presense of the Marshaler.
@@ -667,6 +690,10 @@ type CronJobStatus struct {
667690 // +optional
668691 LastScheduleTime * metav1.Time `json:"lastScheduleTime,omitempty"`
669692
693+ // Information when was the last time the job was successfully scheduled.
694+ // +optional
695+ LastScheduleTime2 Time2 `json:"lastScheduleTime2,omitempty"`
696+
670697 // Information about the last time the job was successfully scheduled,
671698 // with microsecond precision.
672699 // +optional
0 commit comments