Ver Fonte

API v1: image tags are sorted according to their pushed at timestamp (#2932)

Co-authored-by: Porter Support <support@porter.run>
Mohammed Nafees há 3 anos atrás
pai
commit
5d28271068
1 ficheiros alterados com 9 adições e 0 exclusões
  1. 9 0
      internal/registry/registry.go

+ 9 - 0
internal/registry/registry.go

@@ -7,6 +7,7 @@ import (
 	"fmt"
 	"net/http"
 	"net/url"
+	"sort"
 	"strings"
 	"sync"
 	"time"
@@ -1057,6 +1058,14 @@ func (r *Registry) GetECRPaginatedImages(
 		res = append(res, v)
 	}
 
+	sort.Slice(res, func(i, j int) bool {
+		if res[i].PushedAt == nil || res[j].PushedAt == nil {
+			return false
+		}
+
+		return res[i].PushedAt.After(*res[j].PushedAt)
+	})
+
 	return res, resp.NextToken, nil
 }