Skip to content

Commit

Permalink
feat: also fixes bug if the events feed is empty (#73)
Browse files Browse the repository at this point in the history
Signed-off-by: AlexsJones <alexsimonjones@gmail.com>
  • Loading branch information
AlexsJones committed Mar 25, 2023
1 parent 3621766 commit a1093dc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 30 deletions.
15 changes: 7 additions & 8 deletions cmd/find/problems.go → cmd/analyze/analyze.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package find
package analyze

import (
"context"
Expand All @@ -20,9 +20,9 @@ var (
output string
)

// problemsCmd represents the problems command
var problemsCmd = &cobra.Command{
Use: "problems",
// AnalyzeCmd represents the problems command
var AnalyzeCmd = &cobra.Command{
Use: "analyze",
Short: "This command will find problems within your Kubernetes cluster",
Long: `This command will find problems within your Kubernetes cluster and
provide you with a list of issues that need to be resolved`,
Expand Down Expand Up @@ -89,11 +89,10 @@ var problemsCmd = &cobra.Command{

func init() {

problemsCmd.Flags().BoolVarP(&explain, "explain", "e", false, "Explain the problem to me")
AnalyzeCmd.Flags().BoolVarP(&explain, "explain", "e", false, "Explain the problem to me")
// add flag for backend
problemsCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
AnalyzeCmd.Flags().StringVarP(&backend, "backend", "b", "openai", "Backend AI provider")
// output as json
problemsCmd.Flags().StringVarP(&output, "output", "o", "text", "Output format (text, json)")
FindCmd.AddCommand(problemsCmd)
AnalyzeCmd.Flags().StringVarP(&output, "output", "o", "text", "Output format (text, json)")

}
19 changes: 0 additions & 19 deletions cmd/find/find.go

This file was deleted.

4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"os"

"github.com/fatih/color"
"github.com/k8sgpt-ai/k8sgpt/cmd/analyze"
"github.com/k8sgpt-ai/k8sgpt/cmd/auth"
"github.com/k8sgpt-ai/k8sgpt/cmd/find"
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -43,7 +43,7 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.AddCommand(auth.AuthCmd)
rootCmd.AddCommand(find.FindCmd)
rootCmd.AddCommand(analyze.AnalyzeCmd)
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.k8sgpt.git.yaml)")
rootCmd.PersistentFlags().StringVar(&masterURL, "master", "", "The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
rootCmd.PersistentFlags().StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/podAnalyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func AnalyzePod(ctx context.Context, client *kubernetes.Client, aiClient ai.IAI,

// parse the event log and append details
evt, err := FetchLatestPodEvent(ctx, client, &pod)
if err != nil {
if err != nil || evt == nil {
continue
}
if evt.Reason == "FailedCreatePodSandBox" {
Expand Down

0 comments on commit a1093dc

Please sign in to comment.