Skip to content

Commit

Permalink
adding version command
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-dd committed Jun 8, 2024
1 parent 47cea08 commit 804d0c8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cmd/kubehound/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ package main

import (
"fmt"
"os"

"github.com/DataDog/KubeHound/pkg/backend"
"github.com/DataDog/KubeHound/pkg/cmd"
"github.com/DataDog/KubeHound/pkg/config"
"github.com/DataDog/KubeHound/pkg/kubehound/core"
"github.com/DataDog/KubeHound/pkg/telemetry/log"
"github.com/spf13/cobra"
)

var (
cfgFile = ""
skipBackend = false
cfgFile = ""
skipBackend = false
printVersion = false
)

var (
Expand All @@ -21,6 +24,11 @@ var (
Short: "A local Kubehound instance",
Long: `A local instance of Kubehound - a Kubernetes attack path generator`,
PreRunE: func(cobraCmd *cobra.Command, args []string) error {
if printVersion {
log.I.Infof("kubehound version: %s", config.BuildVersion)
os.Exit(0)
}

return cmd.InitializeKubehoundConfig(cobraCmd.Context(), cfgFile, true, false)
},
RunE: func(cobraCmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -60,6 +68,8 @@ var (
)

func init() {
rootCmd.Flags().BoolVarP(&printVersion, "version", "v", printVersion, "print the current version of Kubehound")

rootCmd.Flags().StringVarP(&cfgFile, "config", "c", cfgFile, "application config file")

rootCmd.Flags().BoolVar(&skipBackend, "skip-backend", skipBackend, "skip the auto deployment of the backend stack (janusgraph, mongodb, and UI)")
Expand Down

0 comments on commit 804d0c8

Please sign in to comment.