Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (71 sloc) 2.36 KB
package cmd
import (
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "felix",
Short: "",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
if isShowVersion {
fmt.Println("Golang Env: %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
fmt.Println("UTC build time:%s", buildTime)
fmt.Println("Build from Github repo version:", gitHash)
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute(bTime, gHash string) {
buildTime = bTime
gitHash = gHash
if err := rootCmd.Execute(); err != nil {
var buildTime, gitHash string
var verbose, isShowVersion bool
func init() {
rootCmd.Flags().BoolVarP(&isShowVersion, "version", "v", false, "show binary build information")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "V", false, "verbose")
func initFunc() {
func initSlackLogrus() {
lvl := logrus.InfoLevel
logrus.SetFormatter(&logrus.JSONFormatter{TimestampFormat: "06-01-02T15:04:05", PrettyPrint: true})
mySlackApi := viper.GetString("felix.slack")
HookURL: mySlackApi,
AcceptedLevels: slackrus.LevelThreshold(logrus.ErrorLevel),
Channel: "#Felix",
IconEmoji: ":ghost:",
Username: "Felix",
func initViper() {
viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath(".") // optionally look for config in the working directory
viper.AddConfigPath("/etc/felix/") // path to look for the config file in
viper.AddConfigPath("$HOME/.felix") // call multiple times to add many search paths
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file
logrus.Fatalf("Fatal error config file: %s \n", err)
You can’t perform that action at this time.