mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-18 07:42:20 +00:00
🐛 Fix the version
command
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
"github.com/kubeshark/kubeshark/config"
|
||||
"github.com/kubeshark/kubeshark/kubeshark/version"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -32,13 +31,11 @@ func init() {
|
||||
|
||||
rootCmd.PersistentFlags().StringSlice(config.SetCommandName, []string{}, fmt.Sprintf("Override values using --%s", config.SetCommandName))
|
||||
rootCmd.PersistentFlags().String(config.ConfigFilePathCommandName, defaultConfig.ConfigFilePath, fmt.Sprintf("Override config file path using --%s", config.ConfigFilePathCommandName))
|
||||
rootCmd.PersistentFlags().Bool("debug", false, "Enable debug mode.")
|
||||
rootCmd.PersistentFlags().BoolP("debug", "d", false, "Enable debug mode.")
|
||||
}
|
||||
|
||||
// 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 tapCmd.
|
||||
func Execute() {
|
||||
go version.CheckNewerVersion()
|
||||
|
||||
cobra.CheckErr(rootCmd.Execute())
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/creasty/defaults"
|
||||
"github.com/kubeshark/kubeshark/config/configStructs"
|
||||
"github.com/kubeshark/kubeshark/config"
|
||||
"github.com/kubeshark/kubeshark/kubeshark"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/cobra"
|
||||
@@ -16,24 +16,20 @@ var versionCmd = &cobra.Command{
|
||||
Short: "Print version info",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
timeStampInt, _ := strconv.ParseInt(kubeshark.BuildTimestamp, 10, 0)
|
||||
log.Info().
|
||||
Str("version", kubeshark.Ver).
|
||||
Str("branch", kubeshark.Branch).
|
||||
Str("commit-hash", kubeshark.GitCommitHash).
|
||||
Time("build-time", time.Unix(timeStampInt, 0)).
|
||||
Send()
|
||||
if config.DebugMode {
|
||||
log.Info().
|
||||
Str("version", kubeshark.Ver).
|
||||
Str("branch", kubeshark.Branch).
|
||||
Str("commit-hash", kubeshark.GitCommitHash).
|
||||
Time("build-time", time.Unix(timeStampInt, 0)).
|
||||
Send()
|
||||
} else {
|
||||
fmt.Println(kubeshark.Ver)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
|
||||
defaultVersionConfig := configStructs.VersionConfig{}
|
||||
if err := defaults.Set(&defaultVersionConfig); err != nil {
|
||||
log.Error().Err(err).Send()
|
||||
}
|
||||
|
||||
versionCmd.Flags().BoolP(configStructs.DebugInfoVersionName, "d", defaultVersionConfig.DebugInfo, "Provide all information about version")
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user