forked from lhcb-org/lbpkr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cfg.go
66 lines (54 loc) · 1.31 KB
/
cfg.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
package main
import (
"os"
"strings"
)
type Config interface {
DefaultSiteroot() string
Siteroot() string
RepoUrl() string
Name() string
Debug() bool
RpmUpdate() bool
// RelocateArgs returns the arguments to be passed to RPM for the repositories
RelocateArgs(siteroot string) []string
// RelocateFile returns the relocated file path
RelocateFile(fname, siteroot string) string
InitYum(*Context) error
}
// ConfigBase holds the options and defaults for the installer
type ConfigBase struct {
siteroot string // where to install software, binaries, ...
repourl string
debug bool
rpmupdate bool // install/update switch
}
func (cfg *ConfigBase) Siteroot() string {
return cfg.siteroot
}
func (cfg *ConfigBase) RepoUrl() string {
return cfg.repourl
}
func (cfg *ConfigBase) Debug() bool {
return cfg.debug
}
func (cfg *ConfigBase) RpmUpdate() bool {
return cfg.rpmupdate
}
// NewConfig returns a default configuration value.
func NewConfig(cfgtype, siteroot string) Config {
if siteroot == "" {
paths := strings.Split(os.Getenv("MYSITEROOT"), string(os.PathListSeparator))
siteroot = paths[0]
}
switch cfgtype {
case "atlas":
return newAtlasConfig(siteroot)
case "lhcb":
return newLHCbConfig(siteroot)
default:
panic("lbpkr: unknown config [" + cfgtype + "]")
}
panic("unreachable")
}
// EOF