mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-09-08 18:50:13 +00:00
@@ -3,7 +3,7 @@ package integration
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/common"
|
||||
"github.com/k8sgpt-ai/k8sgpt/pkg/integration/trivy"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ type IIntegration interface {
|
||||
// Remove removes an integration from the cluster
|
||||
UnDeploy(namespace string) error
|
||||
//
|
||||
AddAnalyzer() (string, analyzer.IAnalyzer, error)
|
||||
AddAnalyzer(*map[string]common.IAnalyzer)
|
||||
// RemoveAnalyzer removes an analyzer from the cluster
|
||||
RemoveAnalyzer() error
|
||||
|
||||
@@ -23,6 +23,10 @@ type IIntegration interface {
|
||||
type Integration struct {
|
||||
}
|
||||
|
||||
type IntegrationProvider struct {
|
||||
Active []string `mapstructure:"active"`
|
||||
}
|
||||
|
||||
var integrations = map[string]IIntegration{
|
||||
"trivy": trivy.NewTrivy(),
|
||||
}
|
||||
@@ -39,16 +43,40 @@ func (*Integration) List() []string {
|
||||
return keys
|
||||
}
|
||||
|
||||
func (*Integration) Get(name string) (IIntegration, error) {
|
||||
if _, ok := integrations[name]; !ok {
|
||||
return nil, errors.New("integration not found")
|
||||
}
|
||||
return integrations[name], nil
|
||||
}
|
||||
|
||||
func (*Integration) Activate(name string, namespace string) error {
|
||||
if _, ok := integrations[name]; !ok {
|
||||
return errors.New("integration not found")
|
||||
}
|
||||
return integrations[name].Deploy(namespace)
|
||||
|
||||
if err := integrations[name].Deploy(namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*Integration) Deactivate(name string, namespace string) error {
|
||||
if _, ok := integrations[name]; !ok {
|
||||
return errors.New("integration not found")
|
||||
}
|
||||
return integrations[name].UnDeploy(namespace)
|
||||
|
||||
if err := integrations[name].UnDeploy(namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*Integration) IsActivate(name string) (bool, error) {
|
||||
if _, ok := integrations[name]; !ok {
|
||||
return false, errors.New("integration not found")
|
||||
}
|
||||
return integrations[name].IsActivate(), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user