forked from microsoft/retina
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroot.go
53 lines (44 loc) · 1.33 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
49
50
51
52
53
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
package cmd
import (
"fmt"
"os"
"github.com/microsoft/retina/operator/cmd/legacy"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
const (
configFileName = "retina/operator-config.yaml"
)
var (
metricsAddr string
probeAddr string
enableLeaderElection bool
cfgFile string
rootCmd = &cobra.Command{
Use: "retina-operator",
Short: "Retina Operator",
Long: "Start Retina Operator",
RunE: func(_ *cobra.Command, _ []string) error {
fmt.Println("Starting Retina Operator")
d := legacy.NewOperator(metricsAddr, probeAddr, cfgFile, enableLeaderElection)
if err := d.Start(); err != nil {
return errors.Wrap(err, "failed to start retina-operator")
}
return nil
},
}
)
func init() {
rootCmd.Flags().StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
rootCmd.Flags().StringVar(&probeAddr, "probe-addr", ":8081", "The address the probe endpoint binds to.")
rootCmd.Flags().BoolVar(&enableLeaderElection, "enable-leader-election", false, "Enable leader election for controller manager.")
rootCmd.Flags().StringVar(&cfgFile, "config", configFileName, "config file")
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}