-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
43 lines (35 loc) · 968 Bytes
/
root.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
package cmd
import (
"fmt"
cfg "github.com/marcosQuesada/k8s-swarm/pkg/config"
cfg2 "github.com/marcosQuesada/k8s-swarm/services/worker/internal/config"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"os"
)
const appID = "swarm-worker"
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "root",
Short: "root controller command",
Long: `root controller command`,
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
if err := cfg.BuildLogger(appID); err != nil {
log.Fatalf("unable to unMarshall config, error %v", err)
}
if err := cfg2.LoadConfig(cfg.ConfigFilePath, cfg.ConfigFile); err != nil {
log.Fatalf("unable to unMarshall config, error %v", err)
}
}
func init() {
cobra.OnInitialize(initConfig)
cfg.SetCoreFlags(rootCmd, "worker")
}