Skip to content

Commit 9cfb17a

Browse files
committed
move flag config to the global config
1 parent 30cf579 commit 9cfb17a

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

cmd/gaia/main.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ import (
2020
)
2121

2222
var (
23-
echoInstance *echo.Echo
24-
jwtPrivateKeyPath string
23+
echoInstance *echo.Echo
2524
)
2625

2726
const (
@@ -40,7 +39,7 @@ func init() {
4039
flag.StringVar(&gaia.Cfg.ListenPort, "port", "8080", "Listen port for gaia")
4140
flag.StringVar(&gaia.Cfg.HomePath, "homepath", "", "Path to the gaia home folder")
4241
flag.StringVar(&gaia.Cfg.Worker, "worker", "2", "Number of worker gaia will use to execute pipelines in parallel")
43-
flag.StringVar(&jwtPrivateKeyPath, "jwtPrivateKeyPath", "", "A RSA private key used to sign JWT tokens")
42+
flag.StringVar(&gaia.Cfg.JwtPrivateKeyPath, "jwtPrivateKeyPath", "", "A RSA private key used to sign JWT tokens")
4443
flag.BoolVar(&gaia.Cfg.DevMode, "dev", false, "If true, gaia will be started in development mode. Don't use this in production!")
4544
flag.BoolVar(&gaia.Cfg.VersionSwitch, "version", false, "If true, will print the version and immediately exit")
4645

@@ -67,7 +66,7 @@ func main() {
6766

6867
var jwtKey interface{}
6968
// Check JWT key is set
70-
if jwtPrivateKeyPath == "" {
69+
if gaia.Cfg.JwtPrivateKeyPath == "" {
7170
gaia.Cfg.Logger.Warn("using auto-generated key to sign jwt tokens, do not use in production")
7271
jwtKey = make([]byte, 64)
7372
_, err := rand.Read(jwtKey.([]byte))
@@ -76,7 +75,7 @@ func main() {
7675
os.Exit(1)
7776
}
7877
} else {
79-
keyData, err := ioutil.ReadFile(jwtPrivateKeyPath)
78+
keyData, err := ioutil.ReadFile(gaia.Cfg.JwtPrivateKeyPath)
8079
if err != nil {
8180
gaia.Cfg.Logger.Error("could not read jwt key file", "error", err.Error())
8281
os.Exit(1)

gaia.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,17 @@ var Cfg *Config
145145

146146
// Config holds all config options
147147
type Config struct {
148-
DevMode bool
149-
VersionSwitch bool
150-
ListenPort string
151-
HomePath string
152-
DataPath string
153-
PipelinePath string
154-
WorkspacePath string
155-
Worker string
156-
JWTKey interface{}
157-
Logger hclog.Logger
148+
DevMode bool
149+
VersionSwitch bool
150+
ListenPort string
151+
HomePath string
152+
DataPath string
153+
PipelinePath string
154+
WorkspacePath string
155+
Worker string
156+
JwtPrivateKeyPath string
157+
JWTKey interface{}
158+
Logger hclog.Logger
158159

159160
Bolt struct {
160161
Mode os.FileMode

0 commit comments

Comments
 (0)