Closed clux closed 4 years ago
..although, this isn't really a problem once you understand the underlying type and reach into the inner. This works:
podvec.sort_by_key(|p| {
p.metadata.as_ref().unwrap().creation_timestamp.as_ref().unwrap().0
});
kubectl supports sorting with
--sort-by=.metadata.creationTimestamp
, which we could easily do in memory ifTime
derivedOrd
.https://github.com/Arnavion/k8s-openapi/blob/35cbddfeb26726bc1a0c882a40584c262fb53726/src/v1_17/apimachinery/pkg/apis/meta/v1/time.rs#L4-L5
This should be fine since
chrono::DateTime
- the wrapped type - implements Ord.