Skip to content

Commit d6e4629

Browse files
committed
fix: Tag sort mode for custom registries aren't honored (#93)
1 parent 81b5a6d commit d6e4629

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pkg/registry/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ func LoadRegistryConfiguration(path string, clear bool) error {
4646
}
4747

4848
for _, reg := range registryList.Items {
49-
err = AddRegistryEndpoint(reg.Prefix, reg.Name, reg.ApiURL, reg.Credentials, reg.DefaultNS, reg.Insecure)
49+
tagSortMode := TagListSortFromString(reg.TagSortMode)
50+
err = AddRegistryEndpoint(reg.Prefix, reg.Name, reg.ApiURL, reg.Credentials, reg.DefaultNS, reg.Insecure, tagSortMode)
5051
if err != nil {
5152
return err
5253
}

pkg/registry/endpoints.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var registries map[string]*RegistryEndpoint = make(map[string]*RegistryEndpoint)
100100
var registryLock sync.RWMutex
101101

102102
// AddRegistryEndpoint adds registry endpoint information with the given details
103-
func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, insecure bool) error {
103+
func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, insecure bool, tagListSort TagListSort) error {
104104
registryLock.Lock()
105105
defer registryLock.Unlock()
106106
registries[prefix] = &RegistryEndpoint{
@@ -111,6 +111,7 @@ func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, in
111111
Cache: cache.NewMemCache(),
112112
Insecure: insecure,
113113
DefaultNS: defaultNS,
114+
TagListSort: tagListSort,
114115
}
115116
return nil
116117
}

pkg/registry/endpoints_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func Test_GetEndpoints(t *testing.T) {
3131

3232
func Test_AddEndpoint(t *testing.T) {
3333
t.Run("Add new endpoint", func(t *testing.T) {
34-
err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "", false)
34+
err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "", false, SortUnsorted)
3535
require.NoError(t, err)
3636
})
3737
t.Run("Get example.com endpoint", func(t *testing.T) {
@@ -43,15 +43,17 @@ func Test_AddEndpoint(t *testing.T) {
4343
assert.Equal(t, ep.RegistryAPI, "https://example.com")
4444
assert.Equal(t, ep.Insecure, false)
4545
assert.Equal(t, ep.DefaultNS, "")
46+
assert.Equal(t, ep.TagListSort, SortUnsorted)
4647
})
4748
t.Run("Change existing endpoint", func(t *testing.T) {
48-
err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "library", true)
49+
err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "library", true, SortLatestFirst)
4950
require.NoError(t, err)
5051
ep, err := GetRegistryEndpoint("example.com")
5152
require.NoError(t, err)
5253
require.NotNil(t, ep)
5354
assert.Equal(t, ep.Insecure, true)
5455
assert.Equal(t, ep.DefaultNS, "library")
56+
assert.Equal(t, ep.TagListSort, SortLatestFirst)
5557
})
5658
}
5759

0 commit comments

Comments
 (0)