mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
fix to prioritize newly added registry (#6289)
* fix to prioritize newly added registry Signed-off-by: anandrkskd <anandrkskd@gmail.com> * update RegistryList func to reverse the list and return []Registry Signed-off-by: anandrkskd <anandrkskd@gmail.com> * update the usage of RegistryList Signed-off-by: anandrkskd <anandrkskd@gmail.com> * update unit test and mock Signed-off-by: anandrkskd <anandrkskd@gmail.com> * fix: lint error and check for empty registry list Signed-off-by: anandrkskd <anandrkskd@gmail.com> * add documentation Signed-off-by: anandrkskd <anandrkskd@gmail.com> Signed-off-by: anandrkskd <anandrkskd@gmail.com>
This commit is contained in:
committed by
GitHub
parent
67272fd81d
commit
9a2aa229ce
@@ -60,10 +60,8 @@ func (o RegistryClient) GetDevfileRegistries(registryName string) ([]api.Registr
|
||||
|
||||
hasName := len(registryName) != 0
|
||||
if o.preferenceClient.RegistryList() != nil {
|
||||
registryList := *o.preferenceClient.RegistryList()
|
||||
// Loop backwards here to ensure the registry display order is correct (display latest newly added registry firstly)
|
||||
for i := len(registryList) - 1; i >= 0; i-- {
|
||||
registry := registryList[i]
|
||||
registryList := o.preferenceClient.RegistryList()
|
||||
for _, registry := range registryList {
|
||||
if hasName {
|
||||
if registryName == registry.Name {
|
||||
reg := api.Registry{
|
||||
@@ -241,7 +239,7 @@ func (o RegistryClient) retrieveDevfileDataFromRegistry(registryName string, dev
|
||||
// 2. The devfile api library does not support saving in memory
|
||||
// 3. We need to get the file from the registry and save it to the temporary file
|
||||
// 4. We need to read the file from the temporary file, unmarshal it and then return the devfile data
|
||||
for _, reg = range *registries {
|
||||
for _, reg = range registries {
|
||||
if reg.Name == registryName {
|
||||
err = o.PullStackFromRegistry(reg.URL, devfileName, tmpFile, segment.GetRegistryOptions())
|
||||
if err != nil {
|
||||
|
||||
@@ -48,13 +48,13 @@ OdoSettings:
|
||||
registryName: "",
|
||||
want: []api.Registry{
|
||||
{
|
||||
Name: "DefaultDevfileRegistry",
|
||||
URL: "https://registry.devfile.io",
|
||||
Name: "CheDevfileRegistry",
|
||||
URL: "https://che-devfile-registry.openshift.io/",
|
||||
Secure: false,
|
||||
},
|
||||
{
|
||||
Name: "CheDevfileRegistry",
|
||||
URL: "https://che-devfile-registry.openshift.io/",
|
||||
Name: "DefaultDevfileRegistry",
|
||||
URL: "https://registry.devfile.io",
|
||||
Secure: false,
|
||||
},
|
||||
},
|
||||
@@ -253,7 +253,7 @@ func TestListDevfileStacks(t *testing.T) {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
prefClient := preference.NewMockClient(ctrl)
|
||||
prefClient.EXPECT().RegistryList().Return(&[]preference.Registry{
|
||||
prefClient.EXPECT().RegistryList().Return([]preference.Registry{
|
||||
{
|
||||
Name: "TestRegistry",
|
||||
URL: server.URL,
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func IsSecure(prefClient preference.Client, registryName string) bool {
|
||||
isSecure := false
|
||||
if prefClient.RegistryList() != nil {
|
||||
for _, registry := range *prefClient.RegistryList() {
|
||||
for _, registry := range prefClient.RegistryList() {
|
||||
if registry.Name == registryName && registry.Secure {
|
||||
isSecure = true
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user