-
-
Notifications
You must be signed in to change notification settings - Fork 487
/
strings.go
78 lines (70 loc) · 1.58 KB
/
strings.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package backend
var (
cryptoNameToBackendMap = map[string]CryptoBackend{
"plain": Plain,
"gpgcli": GPGCLI,
"xc": XC,
"openpgp": OpenPGP,
"vault": Vault,
}
cryptoBackendToNameMap = map[CryptoBackend]string{}
rcsNameToBackendMap = map[string]RCSBackend{
"gitcli": GitCLI,
"noop": Noop,
"gogit": GoGit,
}
rcsBackendToNameMap = map[RCSBackend]string{}
storageNameToBackendMap = map[string]StorageBackend{
"inmem": InMem,
"fs": FS,
"consul": Consul,
}
storageBackendToNameMap = map[StorageBackend]string{}
)
func init() {
for k, v := range cryptoNameToBackendMap {
cryptoBackendToNameMap[v] = k
}
for k, v := range rcsNameToBackendMap {
rcsBackendToNameMap[v] = k
}
for k, v := range storageNameToBackendMap {
storageBackendToNameMap[v] = k
}
}
func cryptoBackendFromName(name string) CryptoBackend {
if b, found := cryptoNameToBackendMap[name]; found {
return b
}
return -1
}
func cryptoNameFromBackend(be CryptoBackend) string {
if b, found := cryptoBackendToNameMap[be]; found {
return b
}
return ""
}
func rcsBackendFromName(name string) RCSBackend {
if b, found := rcsNameToBackendMap[name]; found {
return b
}
return -1
}
func rcsNameFromBackend(be RCSBackend) string {
if b, found := rcsBackendToNameMap[be]; found {
return b
}
return ""
}
func storageBackendFromName(name string) StorageBackend {
if b, found := storageNameToBackendMap[name]; found {
return b
}
return FS
}
func storageNameFromBackend(be StorageBackend) string {
if b, found := storageBackendToNameMap[be]; found {
return b
}
return ""
}