Skip to content

Commit

Permalink
fix: dns zone not set correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esonhugh committed Aug 5, 2024
1 parent 2454094 commit 88eb4c7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ var RootCmd = &cobra.Command{
Short: "k8spider is a tool to discover k8s services",
Long: "k8spider is a tool to discover k8s services",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// Set Log Levels
SetLogLevel(Opts.Verbose)
// Set pkg global config
pkg.Zone = Opts.Zone
if Opts.DnsServer != "" {
pkg.NetResolver = pkg.WarpDnsServer(Opts.DnsServer)
}
if Opts.SkipKubeDNSCheck == false { // Not Skip
// Check if current environment is a kubernetes cluster
// If the command is whereisdns, that DNS is not sure , so skip this check
// If SkipKubeDNSCheck is true, skip this check!
if Opts.SkipKubeDNSCheck == false || cmd.Use != "whereisdns" {
if pkg.CheckKubeDNS() {
log.Warn("current environment is not a kubernetes cluster")
os.Exit(1)
}
}
pkg.Zone = Opts.Zone
},
Run: func(cmd *cobra.Command, args []string) {
_ = cmd.Help()
Expand Down

0 comments on commit 88eb4c7

Please sign in to comment.