-
Notifications
You must be signed in to change notification settings - Fork 25
/
config.go
59 lines (51 loc) · 1.84 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 config has definitions about the overall configuration of Collector.
package config
import (
"fmt"
"os"
"time"
flag "github.com/docker/docker/pkg/mflag"
)
const (
// Time to wait before retrying a failed operation.
RETRYDURATION = time.Duration(5) * time.Second
)
var (
FilterRepos = false
// Directories/files dependent on Environment variables
BANYANHOSTDIR = func() string {
if os.Getenv("BANYAN_HOST_DIR") == "" {
os.Setenv("BANYAN_HOST_DIR", os.Getenv("HOME")+"/.banyan")
}
return os.Getenv("BANYAN_HOST_DIR")
}
BANYANDIR = func() string {
if os.Getenv("BANYAN_DIR") != "" {
return os.Getenv("BANYAN_DIR")
}
return BANYANHOSTDIR()
}
COLLECTORDIR = func() string {
if os.Getenv("COLLECTOR_DIR") == "" {
fmt.Fprintf(os.Stderr, "Please set the environment variable COLLECTOR_DIR to the parent")
fmt.Fprintf(os.Stderr, " of the \"data\" scripts directory...\n\n")
//printExampleUsage()
//fmt.Fprintf(os.Stderr, " e.g.,\tcd COLLECTOR_SOURCE_DIRECTORY\n")
//fmt.Fprintf(os.Stderr, "\tsudo COLLECTOR_DIR=$PWD collector [options] REGISTRY [REPO1 REPO2 ...]\n\n")
return ""
}
return os.Getenv("COLLECTOR_DIR")
}
BanyanOutDir = flag.String([]string{"#-banyanoutdir"}, BANYANDIR()+"/hostcollector/banyanout",
"Output directory for collected data")
// Dests is setup as a flag when main calls DefineDestsFlag().
Dests *string
// BanyanUpdate is a function to log interesting updates as collector execution proceeds.
BanyanUpdate BanyanUpdateFunc = func(status ...string) {}
)
type BanyanUpdateFunc func(status ...string)
// DefineDestsFlag is called by the importing package, e.g., main, to create the dests flag.
func DefineDestsFlag(def string) {
Dests = flag.String([]string{"d", "-dests"}, def,
"One or more ',' separated destinations for output generated by scripts. e.g., file or file,custom")
}