wip
This commit is contained in:
committed by
=Michael Hohn
parent
1fdf5064b7
commit
12b9bd9858
5
cmd/commander/cconfig.toml
Normal file
5
cmd/commander/cconfig.toml
Normal file
@@ -0,0 +1,5 @@
|
||||
[commander]
|
||||
[logger]
|
||||
[queue]
|
||||
[storage]
|
||||
[runner]
|
||||
@@ -8,6 +8,8 @@ import (
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -48,11 +50,17 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Read configuration
|
||||
config := loadConfig("cconfig.toml")
|
||||
|
||||
// Apply 'mode' flag
|
||||
switch *mode {
|
||||
case "standalone":
|
||||
// Assemble ccmem
|
||||
case "container":
|
||||
// Assemble cccontainer
|
||||
case "cluster":
|
||||
// Assemble cccluster
|
||||
default:
|
||||
slog.Error("Invalid value for --mode. Allowed values are: standalone, container, cluster\n")
|
||||
os.Exit(1)
|
||||
@@ -62,4 +70,40 @@ func main() {
|
||||
log.Printf("Help: %t\n", *helpFlag)
|
||||
log.Printf("Log Level: %s\n", *logLevel)
|
||||
log.Printf("Mode: %s\n", *mode)
|
||||
|
||||
// Run in the chosen mode
|
||||
|
||||
}
|
||||
|
||||
type CommanderParts struct {
|
||||
commander MCCommander
|
||||
logger MCLogger
|
||||
queue MCQueue
|
||||
storage MCStorage
|
||||
runner MCRunner
|
||||
}
|
||||
|
||||
type MCConfig struct {
|
||||
commander MCCConf
|
||||
logger MCLConf
|
||||
queue MCQConf
|
||||
storage MCSConf
|
||||
runner MCRConf
|
||||
}
|
||||
|
||||
func loadConfig(fname string) *MCConfig {
|
||||
if _, err := os.Stat(fname); err != nil {
|
||||
slog.Error("Configuration file %s not found", f)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var config MCConfig
|
||||
|
||||
_, err := toml.DecodeFile(fname, &config)
|
||||
if err != nil {
|
||||
slog.Error("", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
return &config
|
||||
}
|
||||
|
||||
1
go.mod
1
go.mod
@@ -9,6 +9,7 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.3.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1,3 +1,5 @@
|
||||
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
|
||||
Reference in New Issue
Block a user