Conf Oclib Package Lightest
This commit is contained in:
@@ -9,11 +9,7 @@ import (
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
MonitorPath string
|
MonitorPath string
|
||||||
MongoUrl string
|
|
||||||
DBName string
|
|
||||||
Logs string
|
Logs string
|
||||||
LokiUrl string
|
|
||||||
NatsUrl string
|
|
||||||
Mode string
|
Mode string
|
||||||
KubeHost string
|
KubeHost string
|
||||||
KubePort string
|
KubePort string
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"oc-schedulerd/conf"
|
"oc-schedulerd/conf"
|
||||||
|
|
||||||
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,15 +21,15 @@ type ContainerMonitor struct {
|
|||||||
KubePort string
|
KubePort string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewContainerMonitor(UUID string, peerId string, duration int) (Executor){
|
func NewContainerMonitor(UUID string, peerId string, duration int) Executor {
|
||||||
return &ContainerMonitor{
|
return &ContainerMonitor{
|
||||||
Monitor: LocalMonitor{
|
Monitor: LocalMonitor{
|
||||||
ExecutionID: UUID,
|
ExecutionID: UUID,
|
||||||
PeerID: peerId,
|
PeerID: peerId,
|
||||||
Duration: duration,
|
Duration: duration,
|
||||||
LokiUrl: conf.GetConfig().LokiUrl,
|
LokiUrl: oclib.GetConfig().LokiUrl,
|
||||||
MongoUrl: conf.GetConfig().MongoUrl,
|
MongoUrl: oclib.GetConfig().MongoUrl,
|
||||||
DBName: conf.GetConfig().DBName,
|
DBName: oclib.GetConfig().MongoDatabase,
|
||||||
},
|
},
|
||||||
KubeCA: conf.GetConfig().KubeCA,
|
KubeCA: conf.GetConfig().KubeCA,
|
||||||
KubeCert: conf.GetConfig().KubeCert,
|
KubeCert: conf.GetConfig().KubeCert,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"oc-schedulerd/conf"
|
"oc-schedulerd/conf"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
|
oclib "cloud.o-forge.io/core/oc-lib"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,17 +16,16 @@ type LocalMonitor struct {
|
|||||||
LokiUrl string
|
LokiUrl string
|
||||||
MongoUrl string
|
MongoUrl string
|
||||||
DBName string
|
DBName string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLocalMonitor(UUID string, peerId string, duration int) (Executor){
|
func NewLocalMonitor(UUID string, peerId string, duration int) Executor {
|
||||||
return &LocalMonitor{
|
return &LocalMonitor{
|
||||||
ExecutionID: UUID,
|
ExecutionID: UUID,
|
||||||
PeerID: peerId,
|
PeerID: peerId,
|
||||||
Duration: duration,
|
Duration: duration,
|
||||||
LokiUrl: conf.GetConfig().LokiUrl,
|
LokiUrl: oclib.GetConfig().LokiUrl,
|
||||||
MongoUrl: conf.GetConfig().MongoUrl,
|
MongoUrl: oclib.GetConfig().MongoUrl,
|
||||||
DBName: conf.GetConfig().DBName,
|
DBName: oclib.GetConfig().MongoDatabase,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +46,6 @@ func (lm *LocalMonitor) PrepareMonitorExec() []string {
|
|||||||
"-d", lm.DBName,
|
"-d", lm.DBName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if lm.Duration > 0 {
|
if lm.Duration > 0 {
|
||||||
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
|
args = append(args, "-t", fmt.Sprintf("%d", lm.Duration))
|
||||||
}
|
}
|
||||||
@@ -70,4 +69,3 @@ func (lm *LocalMonitor) LaunchMonitor(args []string, l zerolog.Logger) {
|
|||||||
|
|
||||||
logExecution(stdoutMonitord, l)
|
logExecution(stdoutMonitord, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
main.go
12
main.go
@@ -14,18 +14,6 @@ func main() {
|
|||||||
l := oclib.GetLogger()
|
l := oclib.GetLogger()
|
||||||
o := oclib.GetConfLoader()
|
o := oclib.GetConfLoader()
|
||||||
|
|
||||||
c := oclib.SetConfig(
|
|
||||||
o.GetStringDefault("MONGO_URL", "mongodb://127.0.0.1:27017"),
|
|
||||||
o.GetStringDefault("MONGO_DATABASE", "DC_myDC"),
|
|
||||||
o.GetStringDefault("NATS_URL", "nats://localhost:4222"),
|
|
||||||
o.GetStringDefault("LOKI_URL", ""),
|
|
||||||
o.GetStringDefault("LOG_LEVEL", "info"),
|
|
||||||
)
|
|
||||||
|
|
||||||
conf.GetConfig().DBName = c.MongoDatabase
|
|
||||||
conf.GetConfig().MongoUrl = c.MongoUrl
|
|
||||||
conf.GetConfig().NatsUrl = c.NATSUrl
|
|
||||||
conf.GetConfig().LokiUrl = c.LokiUrl
|
|
||||||
conf.GetConfig().Mode = o.GetStringDefault("MODE", "")
|
conf.GetConfig().Mode = o.GetStringDefault("MODE", "")
|
||||||
|
|
||||||
if conf.GetConfig().Mode == "container" {
|
if conf.GetConfig().Mode == "container" {
|
||||||
|
|||||||
Reference in New Issue
Block a user