Skip to content

Commit

Permalink
Remove undocumented sort type
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexGustafsson committed Dec 22, 2024
1 parent 7325521 commit 1ab6393
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,8 @@ const (
type Sort string

const (
SortReference Sort = "reference"
SortLastModified Sort = "last_modified"
SortBump Sort = "bump"
SortReference Sort = "reference"
SortBump Sort = "bump"
)

type ListImageOptions struct {
Expand Down Expand Up @@ -702,10 +701,9 @@ func (s *Store) ListImages(ctx context.Context, options *ListImageOptions) (*mod
// NOTE: This mapping is done to hard code strings used in SQL queries to
// prevent injection attacks
sort, ok := map[Sort]string{
"": "bump",
SortReference: "reference",
SortLastModified: "last_modified",
SortBump: "bump",
"": "bump",
SortReference: "reference",
SortBump: "bump",
}[options.Sort]
if !ok {
return nil, fmt.Errorf("invalid sort")
Expand Down Expand Up @@ -814,8 +812,6 @@ func (s *Store) ListImages(ctx context.Context, options *ListImageOptions) (*mod
switch sort {
case "reference":
orderClause = "ORDER BY images.reference " + order
case "last_modified":
orderClause = "ORDER BY images.last_modified " + order
case "bump":
orderClause = "ORDER BY images.versionDiffSortable " + order + ", images.reference"
}
Expand Down

0 comments on commit 1ab6393

Please sign in to comment.