-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.go
59 lines (49 loc) · 1.1 KB
/
config.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
package dldataset
import (
"github.com/k0kubun/pp"
"github.com/rai-project/config"
"github.com/rai-project/vipertags"
)
type dldatasetConfig struct {
WorkingDirectory string `json:"working_directory" config:"dldataset.working_directory" default:""`
done chan struct{} `json:"-" config:"-"`
}
// Config ...
var (
// Config holds the data read by rai-project/config
Config = &dldatasetConfig{
done: make(chan struct{}),
}
)
// ConfigName ...
func (dldatasetConfig) ConfigName() string {
return "DLDataset"
}
// SetDefaults ...
func (c *dldatasetConfig) SetDefaults() {
vipertags.SetDefaults(c)
}
// Read ...
func (c *dldatasetConfig) Read() {
defer close(c.done)
config.App.Wait()
vipertags.Fill(c)
if c.WorkingDirectory == "" || c.WorkingDirectory == "default" {
c.WorkingDirectory = config.App.TempDir
}
}
// Wait ...
func (c dldatasetConfig) Wait() {
<-c.done
}
// String ...
func (c dldatasetConfig) String() string {
return pp.Sprintln(c)
}
// Debug ...
func (c dldatasetConfig) Debug() {
log.Debug("DLDataset Config = ", c)
}
func init() {
config.Register(Config)
}