Files
odo/pkg/registry/utils.go
Anand Kumar Singh 9a2aa229ce 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>
2022-11-16 17:31:52 +00:00

38 lines
813 B
Go

package registry
import (
"fmt"
url2 "net/url"
"strings"
"github.com/redhat-developer/odo/pkg/preference"
)
// IsSecure checks if the registry is secure
func IsSecure(prefClient preference.Client, registryName string) bool {
isSecure := false
if prefClient.RegistryList() != nil {
for _, registry := range prefClient.RegistryList() {
if registry.Name == registryName && registry.Secure {
isSecure = true
break
}
}
}
return isSecure
}
func IsGithubBasedRegistry(url string) (bool, error) {
pu, err := url2.Parse(url)
if err != nil {
return false, fmt.Errorf("unable to parse registry url %w", err)
}
for _, d := range []string{"github.com", "raw.githubusercontent.com"} {
if pu.Host == d || strings.HasSuffix(pu.Host, "."+d) {
return true, nil
}
}
return false, nil
}