-
Notifications
You must be signed in to change notification settings - Fork 28
/
sitedefaults.go
68 lines (62 loc) · 2 KB
/
sitedefaults.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
// Copyright 2018 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package flags
import (
"v.io/v23/rpc"
"v.io/x/ref/lib/flags/sitedefaults"
)
var defaultValues = []map[string]interface{}{}
func mergeDefaultValues() map[string]interface{} {
merged := map[string]interface{}{}
for _, v := range defaultValues {
for name, val := range v {
merged[name] = val
}
}
return merged
}
func registerDefaults(values map[string]interface{}) {
defaultValues = append(defaultValues, values)
}
func init() {
registerDefaults(map[string]interface{}{
"namespaceRoots": []string{
"/(dev.v.io:r:vprod:service:mounttabled)@ns.dev.v.io:8101",
},
"credentialsDir": "",
"protocol": "wsh",
"hostPort": ":0",
"proxy": "",
"proxyPolicy": rpc.UseRandomProxy,
"proxyLimit": 0,
"permissionsLiteral": "",
"permissions": map[string]string{},
"vtrace": VtraceFlags{
SampleRate: 0.0,
DumpOnShutdown: true,
CacheSize: 1024,
LogLevel: 0,
CollectRegexp: "",
EnableAWSXRay: false,
},
"virtualized": VirtualizedFlagDefaults{
VirtualizationProvider: string(Native),
PublicProtocol: "wsh",
AdvertisePrivateAddresses: true,
},
})
registerDefaults(sitedefaults.Defaults)
merged := mergeDefaultValues()
defaultNamespaceRoots = merged["namespaceRoots"].([]string)
defaultCredentialsDir = merged["credentialsDir"].(string)
defaultProtocol = merged["protocol"].(string)
defaultHostPort = merged["hostPort"].(string)
defaultProxy = merged["proxy"].(string)
defaultProxyPolicy = merged["proxyPolicy"].(rpc.ProxyPolicy)
defaultProxyLimit = merged["proxyLimit"].(int)
defaultPermissionsLiteral = merged["permissionsLiteral"].(string)
defaultPermissions = merged["permissions"].(map[string]string)
defaultVirtualized = merged["virtualized"].(VirtualizedFlagDefaults)
defaultVtrace = merged["vtrace"].(VtraceFlags)
}