mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-06-22 13:38:34 +00:00
Merge pull request #334 from patrickpichler/fix/various-linter-reported-issues
fix: various linter reported issues
This commit is contained in:
commit
10f49e6146
@ -26,7 +26,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
port string
|
port string
|
||||||
backend string
|
backend string
|
||||||
token string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var ServeCmd = &cobra.Command{
|
var ServeCmd = &cobra.Command{
|
||||||
|
@ -2,7 +2,4 @@ package ai
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
default_prompt = "Simplify the following Kubernetes error message and provide a solution in %s: %s"
|
default_prompt = "Simplify the following Kubernetes error message and provide a solution in %s: %s"
|
||||||
prompt_a = "Read the following input %s and provide possible scenarios for remediation in %s"
|
|
||||||
prompt_b = "Considering the following input from the Kubernetes resource %s and the error message %s, provide possible scenarios for remediation in %s"
|
|
||||||
prompt_c = "Reading the following %s error message and it's accompanying log message %s, how would you simplify this message?"
|
|
||||||
)
|
)
|
||||||
|
@ -33,11 +33,9 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
|
|||||||
"analyzer_name": kind,
|
"analyzer_name": kind,
|
||||||
})
|
})
|
||||||
|
|
||||||
var results []common.Result
|
|
||||||
|
|
||||||
cronJobList, err := a.Client.GetClient().BatchV1().CronJobs(a.Namespace).List(a.Context, v1.ListOptions{})
|
cronJobList, err := a.Client.GetClient().BatchV1().CronJobs(a.Namespace).List(a.Context, v1.ListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return results, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var preAnalysis = map[string]common.PreAnalysis{}
|
var preAnalysis = map[string]common.PreAnalysis{}
|
||||||
@ -114,7 +112,7 @@ func (analyzer CronJobAnalyzer) Analyze(a common.Analyzer) ([]common.Result, err
|
|||||||
Name: key,
|
Name: key,
|
||||||
Error: value.FailureDetails,
|
Error: value.FailureDetails,
|
||||||
}
|
}
|
||||||
a.Results = append(results, currentAnalysis)
|
a.Results = append(a.Results, currentAnalysis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,23 +54,23 @@ func (NetworkPolicyAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error)
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
continue
|
} else {
|
||||||
}
|
// Check if policy is not applied to any pods
|
||||||
// Check if policy is not applied to any pods
|
podList, err := util.GetPodListByLabels(a.Client.GetClient(), a.Namespace, policy.Spec.PodSelector.MatchLabels)
|
||||||
podList, err := util.GetPodListByLabels(a.Client.GetClient(), a.Namespace, policy.Spec.PodSelector.MatchLabels)
|
if err != nil {
|
||||||
if err != nil {
|
return nil, err
|
||||||
return nil, err
|
}
|
||||||
}
|
if len(podList.Items) == 0 {
|
||||||
if len(podList.Items) == 0 {
|
failures = append(failures, common.Failure{
|
||||||
failures = append(failures, common.Failure{
|
Text: fmt.Sprintf("Network policy is not applied to any pods: %s", policy.Name),
|
||||||
Text: fmt.Sprintf("Network policy is not applied to any pods: %s", policy.Name),
|
Sensitive: []common.Sensitive{
|
||||||
Sensitive: []common.Sensitive{
|
{
|
||||||
{
|
Unmasked: policy.Name,
|
||||||
Unmasked: policy.Name,
|
Masked: util.MaskString(policy.Name),
|
||||||
Masked: util.MaskString(policy.Name),
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(failures) > 0 {
|
if len(failures) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user