-
Notifications
You must be signed in to change notification settings - Fork 90
/
peek.go
45 lines (38 loc) · 1.14 KB
/
peek.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package upstream
import (
"net/url"
"github.com/pkg/errors"
types "github.com/replicatedhq/kots/pkg/upstream/types"
"github.com/replicatedhq/kots/pkg/util"
)
func GetUpdatesUpstream(upstreamURI string, fetchOptions *types.FetchOptions) (*types.UpdateCheckResult, error) {
updates, err := getUpdatesUpstream(upstreamURI, fetchOptions)
if err != nil {
return nil, errors.Wrap(err, "download upstream failed")
}
return updates, nil
}
func getUpdatesUpstream(upstreamURI string, fetchOptions *types.FetchOptions) (*types.UpdateCheckResult, error) {
if !util.IsURL(upstreamURI) {
return nil, errors.New("not implemented")
}
u, err := url.ParseRequestURI(upstreamURI)
if err != nil {
return nil, errors.Wrap(err, "parse request uri failed")
}
if u.Scheme == "helm" {
return getUpdatesHelm(u, fetchOptions.HelmRepoURI)
}
if u.Scheme == "replicated" {
return getUpdatesReplicated(u, fetchOptions)
}
if u.Scheme == "git" {
// return getUpdatesGit(upstreamURI)
// TODO
}
if u.Scheme == "http" || u.Scheme == "https" {
// return getUpdatesHttp(upstreamURI)
// TODO
}
return nil, errors.Errorf("unknown protocol scheme %q", u.Scheme)
}