Dockerfile for scheduler
This commit is contained in:
59
conf/conf.go
Normal file
59
conf/conf.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package conf
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/beego/beego/logs"
|
||||
"github.com/goraz/onion"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
OcCatalogUrl string
|
||||
Logs string
|
||||
}
|
||||
|
||||
var instance *Config
|
||||
var once sync.Once
|
||||
|
||||
const defaultConfigFile = "/app/conf/scheduler.json"
|
||||
const localConfigFile = "./conf/local_scheduler.json"
|
||||
|
||||
|
||||
func init(){
|
||||
|
||||
configFile := ""
|
||||
var o *onion.Onion
|
||||
|
||||
l3 := onion.NewEnvLayerPrefix("_", "OCSCHEDULER_")
|
||||
l2, err := onion.NewFileLayer(defaultConfigFile, nil)
|
||||
if err == nil {
|
||||
logs.Info("Config file found : " + defaultConfigFile)
|
||||
configFile = defaultConfigFile
|
||||
}
|
||||
l1, err := onion.NewFileLayer(localConfigFile, nil)
|
||||
if err == nil {
|
||||
logs.Info("Local config file found " + localConfigFile + ", overriding default file")
|
||||
configFile = localConfigFile
|
||||
}
|
||||
if configFile == "" {
|
||||
logs.Info("No config file found, using env")
|
||||
o = onion.New(l3)
|
||||
} else if l1 == nil && l2 == nil {
|
||||
o = onion.New(l1, l2, l3)
|
||||
} else if l1 == nil {
|
||||
o = onion.New(l2, l3)
|
||||
} else if l2 == nil {
|
||||
o = onion.New(l1, l3)
|
||||
}
|
||||
|
||||
GetConfig().OcCatalogUrl = o.GetStringDefault("oc-catalog", "https://localhost:49618")
|
||||
GetConfig().Logs = o.GetStringDefault("loglevel", "info")
|
||||
|
||||
}
|
||||
|
||||
func GetConfig() *Config {
|
||||
once.Do(func() {
|
||||
instance = &Config{}
|
||||
})
|
||||
return instance
|
||||
}
|
||||
3
conf/docker_scheduler.json
Normal file
3
conf/docker_scheduler.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"oc-catalog" : "http://oc-catalog:49618/"
|
||||
}
|
||||
3
conf/local_scheduler.json
Normal file
3
conf/local_scheduler.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"oc-catalog" : "http://localhost:49618/"
|
||||
}
|
||||
Reference in New Issue
Block a user