forked from keybase/client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sources.go
36 lines (28 loc) · 844 Bytes
/
sources.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
package sources
import (
"fmt"
"github.com/keybase/client/go/libkb"
keybase1 "github.com/keybase/client/go/protocol"
)
type UpdateSource interface {
FindUpdate(config keybase1.UpdateConfig) (*keybase1.Update, error)
}
type Source string
const (
KeybaseSource Source = "keybase"
GithubSource = "github"
RemoteSource = "remote"
DefaultSource = ""
)
var Sources = []Source{KeybaseSource, GithubSource, DefaultSource}
func UpdateSourceForName(g *libkb.GlobalContext, name string) (UpdateSource, error) {
switch name {
case string(DefaultSource), string(KeybaseSource):
return NewKeybaseUpdateSource(g), nil
case string(GithubSource):
return NewGithubUpdateSource(g), nil
case string(RemoteSource):
return NewRemoteUpdateSource(g), nil
}
return nil, fmt.Errorf("Invalid update source: %s", name)
}