...
1 package registry
2
3 import (
4 "fmt"
5 url2 "net/url"
6 "strings"
7
8 "github.com/redhat-developer/odo/pkg/preference"
9 )
10
11
12 func IsSecure(prefClient preference.Client, registryName string) bool {
13 isSecure := false
14 if prefClient.RegistryList() != nil {
15 for _, registry := range prefClient.RegistryList() {
16 if registry.Name == registryName && registry.Secure {
17 isSecure = true
18 break
19 }
20 }
21 }
22
23 return isSecure
24 }
25
26 func IsGithubBasedRegistry(url string) (bool, error) {
27 pu, err := url2.Parse(url)
28 if err != nil {
29 return false, fmt.Errorf("unable to parse registry url %w", err)
30 }
31 for _, d := range []string{"github.com", "raw.githubusercontent.com"} {
32 if pu.Host == d || strings.HasSuffix(pu.Host, "."+d) {
33 return true, nil
34 }
35 }
36 return false, nil
37 }
38
View as plain text