-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.go
More file actions
67 lines (51 loc) · 1.53 KB
/
default.go
File metadata and controls
67 lines (51 loc) · 1.53 KB
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
package config
import (
"sync"
"github.com/go-kit/log"
"github.com/helios-live/go-config/v2/pkg/interfaces"
)
// DefaultManager is the base DefaultManager object
type DefaultManager struct {
*sync.Mutex
// FilePath represents the path to the config file
FilePath string `json:"-" yaml:"-"`
// fullURL represents the full url passed to config.New
fullURL string `json:"-" yaml:"-"`
// Repo is responsible for interracting with the storage medium
Repo interfaces.Repository `json:"-" yaml:"-"`
// Marsh is responsible for serializing and deserializing data
Marsh interfaces.Marshaler `json:"-" yaml:"-"`
Log log.Logger `json:"-" yaml:"-"`
// should we check the path extension and determine the appropriate
// marshaller?
// Default: true
AutoDetectMarshaller bool `json:"-" yaml:"-"`
}
// Repository returns the repository
func (c DefaultManager) Repository() interfaces.Repository {
return c.Repo
}
// Marshaler returns the repository
func (c DefaultManager) Marshaler() interfaces.Marshaler {
return c.Marsh
}
// Logger returns the logger
func (c DefaultManager) Logger() log.Logger {
return c.Log
}
// Path returns the path of the manager
func (c DefaultManager) Path() string {
return c.FilePath
}
// Load .
func (c DefaultManager) Load(data interface{}) error {
return c.Repository().Load(c, data)
}
// Save .
func (c DefaultManager) Save(data interface{}) error {
return c.Repository().Save(c, data)
}
// FullURL returns the full url passed to config.New
func (c DefaultManager) FullURL() string {
return c.fullURL
}