-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
342eedf
commit b229d56
Showing
14 changed files
with
1,023 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func Collect() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "collect", | ||
Short: "collect a support bundle from a cluster", | ||
Long: `...`, | ||
PreRun: func(cmd *cobra.Command, args []string) { | ||
viper.BindPFlag("collectors", cmd.Flags().Lookup("collectors")) | ||
viper.BindPFlag("namespace", cmd.Flags().Lookup("namespace")) | ||
viper.BindPFlag("kubecontext", cmd.Flags().Lookup("kubecontext")) | ||
}, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
cmd.Flags().String("collectors", "", "name of the collectors to use") | ||
cmd.Flags().String("namespace", "", "namespace the collectors can be found in") | ||
|
||
cmd.Flags().String("kubecontext", "", "the kubecontext to use when connecting") | ||
|
||
viper.BindPFlags(cmd.Flags()) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func RootCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "troubleshoot", | ||
Short: "Generate and manage support bundles", | ||
Long: `A support bundle is an archive of files, output, metrics and state | ||
from a server that can be used to assist when troubleshooting a server.`, | ||
SilenceUsage: true, | ||
} | ||
|
||
cobra.OnInitialize(initConfig) | ||
|
||
cmd.AddCommand(Collect()) | ||
|
||
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) | ||
return cmd | ||
} | ||
|
||
func InitAndExecute() { | ||
if err := RootCmd().Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func initConfig() { | ||
viper.SetEnvPrefix("TROUBLESHOT") | ||
viper.AutomaticEnv() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/replicatedhq/troubleshoot/cmd/troubleshoot/cli" | ||
|
||
func main() { | ||
cli.InitAndExecute() | ||
} |
Oops, something went wrong.