diff options
| author | jannfis <jann@mistrust.net> | 2020-09-25 09:55:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-25 09:55:39 +0200 |
| commit | c9142d4d8a493316700ee682a80c8ef9bef1e053 (patch) | |
| tree | 16eabf3717dfd877e846d70fada1008485f8fbb6 | |
| parent | b7f86c149e581bcbf7b729ef693b685c5be6c0a6 (diff) | |
fix: Tag sort mode for custom registries aren't honored (#93)
| -rw-r--r-- | pkg/registry/config.go | 3 | ||||
| -rw-r--r-- | pkg/registry/endpoints.go | 3 | ||||
| -rw-r--r-- | pkg/registry/endpoints_test.go | 6 |
3 files changed, 8 insertions, 4 deletions
diff --git a/pkg/registry/config.go b/pkg/registry/config.go index f4c8133..f9ef716 100644 --- a/pkg/registry/config.go +++ b/pkg/registry/config.go @@ -46,7 +46,8 @@ func LoadRegistryConfiguration(path string, clear bool) error { } for _, reg := range registryList.Items { - err = AddRegistryEndpoint(reg.Prefix, reg.Name, reg.ApiURL, reg.Credentials, reg.DefaultNS, reg.Insecure) + tagSortMode := TagListSortFromString(reg.TagSortMode) + err = AddRegistryEndpoint(reg.Prefix, reg.Name, reg.ApiURL, reg.Credentials, reg.DefaultNS, reg.Insecure, tagSortMode) if err != nil { return err } diff --git a/pkg/registry/endpoints.go b/pkg/registry/endpoints.go index e5486f7..e2e726b 100644 --- a/pkg/registry/endpoints.go +++ b/pkg/registry/endpoints.go @@ -100,7 +100,7 @@ var registries map[string]*RegistryEndpoint = make(map[string]*RegistryEndpoint) var registryLock sync.RWMutex // AddRegistryEndpoint adds registry endpoint information with the given details -func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, insecure bool) error { +func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, insecure bool, tagListSort TagListSort) error { registryLock.Lock() defer registryLock.Unlock() registries[prefix] = &RegistryEndpoint{ @@ -111,6 +111,7 @@ func AddRegistryEndpoint(prefix, name, apiUrl, credentials, defaultNS string, in Cache: cache.NewMemCache(), Insecure: insecure, DefaultNS: defaultNS, + TagListSort: tagListSort, } return nil } diff --git a/pkg/registry/endpoints_test.go b/pkg/registry/endpoints_test.go index 5cb4d1e..3d16044 100644 --- a/pkg/registry/endpoints_test.go +++ b/pkg/registry/endpoints_test.go @@ -31,7 +31,7 @@ func Test_GetEndpoints(t *testing.T) { func Test_AddEndpoint(t *testing.T) { t.Run("Add new endpoint", func(t *testing.T) { - err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "", false) + err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "", false, SortUnsorted) require.NoError(t, err) }) t.Run("Get example.com endpoint", func(t *testing.T) { @@ -43,15 +43,17 @@ func Test_AddEndpoint(t *testing.T) { assert.Equal(t, ep.RegistryAPI, "https://example.com") assert.Equal(t, ep.Insecure, false) assert.Equal(t, ep.DefaultNS, "") + assert.Equal(t, ep.TagListSort, SortUnsorted) }) t.Run("Change existing endpoint", func(t *testing.T) { - err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "library", true) + err := AddRegistryEndpoint("example.com", "Example", "https://example.com", "", "library", true, SortLatestFirst) require.NoError(t, err) ep, err := GetRegistryEndpoint("example.com") require.NoError(t, err) require.NotNil(t, ep) assert.Equal(t, ep.Insecure, true) assert.Equal(t, ep.DefaultNS, "library") + assert.Equal(t, ep.TagListSort, SortLatestFirst) }) } |
