-
Notifications
You must be signed in to change notification settings - Fork 4
/
global.go
71 lines (58 loc) · 1.95 KB
/
global.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
package venom
var v *Venom
func init() {
v = Default()
}
// RegisterResolver registers a custom config resolver into the global venom
// instance
func RegisterResolver(level ConfigLevel, r Resolver) {
v.RegisterResolver(level, r)
}
// Alias registers an alias for a given key in the global venom instance
func Alias(from, to string) {
v.Alias(from, to)
}
// SetLevel is a generic key/value setter method. It sets the provided k/v at
// the specified level inside the global venom instance.
func SetLevel(level ConfigLevel, key string, value interface{}) {
v.SetLevel(level, key, value)
}
// SetDefault sets the provided key and value into the global venom instance at
// the default level
func SetDefault(key string, value interface{}) {
v.SetDefault(key, value)
}
// SetOverride sets the provided key and value into the global venom instance at
// the override level
func SetOverride(key string, value interface{}) {
v.SetOverride(key, value)
}
// Get retrieves the requested key from the global venom instance
func Get(key string) interface{} {
return v.Get(key)
}
// Find searches for the given key, returning the discovered value and a
// boolean indicating whether or not the key was found
func Find(key string) (interface{}, bool) {
return v.Find(key)
}
// LoadFile loads the file from the provided path into Venoms configs. If the
// file can't be opened, if no loader for the files extension exists, or if
// loading the file fails, an error is returned
func LoadFile(name string) error {
return v.LoadFile(name)
}
// LoadDirectory loads any config files found in the provided directory,
// optionally recursing into any sub-directories
func LoadDirectory(dir string, recurse bool) error {
return v.LoadDirectory(dir, recurse)
}
// Clear removes all data from the ConfigMap and resets the heap of config
// levels
func Clear() {
v.Clear()
}
// Debug returns the current venom ConfigMap as a pretty-printed JSON string
func Debug() string {
return v.Debug()
}