mirror of
https://github.com/k8sgpt-ai/k8sgpt.git
synced 2025-04-27 19:15:24 +00:00
Signed-off-by: AlexsJones <alexsimonjones@gmail.com> Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package integration
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/k8sgpt-ai/k8sgpt/pkg/analyzer"
|
|
"github.com/k8sgpt-ai/k8sgpt/pkg/integration/trivy"
|
|
)
|
|
|
|
type IIntegration interface {
|
|
// Add adds an integration to the cluster
|
|
Deploy(namespace string) error
|
|
// Remove removes an integration from the cluster
|
|
UnDeploy(namespace string) error
|
|
//
|
|
AddAnalyzer() (string, analyzer.IAnalyzer, error)
|
|
// RemoveAnalyzer removes an analyzer from the cluster
|
|
RemoveAnalyzer() error
|
|
|
|
IsActivate() bool
|
|
}
|
|
|
|
type Integration struct {
|
|
}
|
|
|
|
var integrations = map[string]IIntegration{
|
|
"trivy": trivy.NewTrivy(),
|
|
}
|
|
|
|
func NewIntegration() *Integration {
|
|
return &Integration{}
|
|
}
|
|
|
|
func (*Integration) List() []string {
|
|
keys := make([]string, 0, len(integrations))
|
|
for k := range integrations {
|
|
keys = append(keys, k)
|
|
}
|
|
return keys
|
|
}
|
|
|
|
func (*Integration) Activate(name string, namespace string) error {
|
|
if _, ok := integrations[name]; !ok {
|
|
return errors.New("integration not found")
|
|
}
|
|
return integrations[name].Deploy(namespace)
|
|
}
|
|
|
|
func (*Integration) Deactivate(name string, namespace string) error {
|
|
if _, ok := integrations[name]; !ok {
|
|
return errors.New("integration not found")
|
|
}
|
|
return integrations[name].UnDeploy(namespace)
|
|
}
|