1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
package sort
// import (
// "sort"
// "google.golang.org/protobuf/ptypes"
// pb "github.com/hashicorp/vagrant/internal/server/gen"
// )
// // DeploymentStartDesc sorts deployments by start time descending.
// type DeploymentStartDesc []*pb.Deployment
// func (s DeploymentStartDesc) Len() int { return len(s) }
// func (s DeploymentStartDesc) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// func (s DeploymentStartDesc) Less(i, j int) bool {
// t1, err := ptypes.Timestamp(s[i].Status.StartTime)
// if err != nil {
// return false
// }
// t2, err := ptypes.Timestamp(s[j].Status.StartTime)
// if err != nil {
// return false
// }
// return t2.Before(t1)
// }
// // DeploymentCompleteDesc sorts deployments by completion time descending.
// type DeploymentCompleteDesc []*pb.Deployment
// func (s DeploymentCompleteDesc) Len() int { return len(s) }
// func (s DeploymentCompleteDesc) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// func (s DeploymentCompleteDesc) Less(i, j int) bool {
// t1, err := ptypes.Timestamp(s[i].Status.CompleteTime)
// if err != nil {
// return false
// }
// t2, err := ptypes.Timestamp(s[j].Status.CompleteTime)
// if err != nil {
// return false
// }
// return t2.Before(t1)
// }
// var (
// _ sort.Interface = (DeploymentStartDesc)(nil)
// _ sort.Interface = (DeploymentCompleteDesc)(nil)
// )
|