-
Notifications
You must be signed in to change notification settings - Fork 127
/
root.go
48 lines (41 loc) · 1.19 KB
/
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
44
45
46
47
48
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/armadaproject/armada/internal/common"
commonconfig "github.com/armadaproject/armada/internal/common/config"
schedulerconfig "github.com/armadaproject/armada/internal/scheduler/configuration"
)
const (
CustomConfigLocation string = "config"
)
func RootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "scheduler",
SilenceUsage: true,
Short: "The main armada scheduler",
}
cmd.PersistentFlags().StringSlice(
CustomConfigLocation,
[]string{},
"Fully qualified path to application configuration file (for multiple config files repeat this arg or separate paths with commas)")
err := viper.BindPFlag(CustomConfigLocation, cmd.PersistentFlags().Lookup(CustomConfigLocation))
if err != nil {
panic(err)
}
cmd.AddCommand(
runCmd(),
migrateDbCmd(),
pruneDbCmd(),
)
return cmd
}
func loadConfig() (schedulerconfig.Configuration, error) {
var config schedulerconfig.Configuration
common.LoadConfig(&config, "./config/scheduler", viper.GetStringSlice(CustomConfigLocation))
err := config.Validate()
if err != nil {
commonconfig.LogValidationErrors(err)
}
return config, err
}