mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-09 03:01:16 +00:00
feat: enables remote custom analyzers (#906)
* feat: enables remote custom analyzers Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: fixed test that was broken Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: hiding custom analysis behind a flag Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: resolved govet issue Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated deps Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated deps Signed-off-by: Alex Jones <alexsimonjones@gmail.com> --------- Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/cache"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/custom"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/kubernetes"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/util"
|
||||
"github.com/schollz/progressbar/v3"
|
||||
@@ -50,8 +51,10 @@ type Analysis struct {
|
||||
WithDoc bool
|
||||
}
|
||||
|
||||
type AnalysisStatus string
|
||||
type AnalysisErrors []string
|
||||
type (
|
||||
AnalysisStatus string
|
||||
AnalysisErrors []string
|
||||
)
|
||||
|
||||
const (
|
||||
StateOK AnalysisStatus = "OK"
|
||||
@@ -147,6 +150,27 @@ func NewAnalysis(
|
||||
return a, nil
|
||||
}
|
||||
|
||||
func (a *Analysis) RunCustomAnalysis() {
|
||||
var customAnalyzers []custom.CustomAnalyzer
|
||||
if err := viper.UnmarshalKey("custom_analyzers", &customAnalyzers); err != nil {
|
||||
a.Errors = append(a.Errors, err.Error())
|
||||
}
|
||||
|
||||
for _, cAnalyzer := range customAnalyzers {
|
||||
|
||||
canClient, err := custom.NewClient(cAnalyzer.Connection)
|
||||
if err != nil {
|
||||
a.Errors = append(a.Errors, fmt.Sprintf("Client creation error for %s analyzer", cAnalyzer.Name))
|
||||
continue
|
||||
}
|
||||
|
||||
result, err := canClient.Run()
|
||||
if err != nil {
|
||||
a.Results = append(a.Results, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *Analysis) RunAnalysis() {
|
||||
activeFilters := viper.GetStringSlice("active_filters")
|
||||
|
||||
|
Reference in New Issue
Block a user