feat: lists activate integrations (#669)

Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
This commit is contained in:
Alex Jones
2023-09-19 17:15:07 +01:00
committed by GitHub
parent d6b7b818ae
commit 844ff1fc78
4 changed files with 43 additions and 2 deletions

5
go.mod
View File

@@ -24,13 +24,14 @@ require (
require github.com/adrg/xdg v0.4.0
require (
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230830164712-dc062a152c20.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230830164712-dc062a152c20.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230919114723-34e017906403.1
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230919114723-34e017906403.1
github.com/aws/aws-sdk-go v1.45.11
github.com/cohere-ai/cohere-go v0.2.0
)
require (
buf.build/gen/go/k8sgpt-ai/k8sgpt/connectrpc/go v1.11.1-20230919114723-34e017906403.1 // indirect
github.com/anchore/go-struct-converter v0.0.0-20221118182256-c68fdcfa2092 // indirect
github.com/cohere-ai/tokenizer v1.1.1 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect

7
go.sum
View File

@@ -1,8 +1,15 @@
buf.build/gen/go/k8sgpt-ai/k8sgpt/connectrpc/go v1.11.1-20230919114723-34e017906403.1 h1:4ffb19hBiaHhWaJN5F7Kg08lIHDK7SkHsWh+gGrjmoc=
buf.build/gen/go/k8sgpt-ai/k8sgpt/connectrpc/go v1.11.1-20230919114723-34e017906403.1/go.mod h1:H26axo1Ku8cV8oAhejdNaiFAUduB82WuTB6HNM6f4uQ=
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230830164712-dc062a152c20.1 h1:BxfODEGSX+jnZaMNsJzwTmAFlyeUwKwHMCCGogFVcFQ=
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230830164712-dc062a152c20.1/go.mod h1:SlLN7iYOcqgVZxFNWKzlZZTV5eQ1q9Yh4Lu/ZEnrU14=
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230919114723-34e017906403.1 h1:OMpJ48yTsJ12DDJlhpNXTZOfNEfkrcAwGqgSvL1vg7U=
buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230919114723-34e017906403.1/go.mod h1:cc42fuhIhL3qTsCrT4dK0kZ5u6hm02WJraREmSVZHmA=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230830164712-dc062a152c20.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230919114723-34e017906403.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230830164712-dc062a152c20.1 h1:oD5YCdsVnQgVLSHxium66FFfuxjjvn5u65mnQo6vAyc=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230830164712-dc062a152c20.1/go.mod h1:gtnk2yAUexdY5nTuUg0SH5WCCGvpKzr7pd3Xbi7MWjE=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230919114723-34e017906403.1 h1:rn//G20ZMgHwnfl7shj5zmpDgzS8aZsoVkeJ7+fMkfo=
buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.31.0-20230919114723-34e017906403.1/go.mod h1:gtnk2yAUexdY5nTuUg0SH5WCCGvpKzr7pd3Xbi7MWjE=
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=

View File

@@ -15,3 +15,12 @@ e.g.
grpcurl -plaintext -d '{"namespace": "k8sgpt", "explain" : "true"}' localhost:8080 schema.v1.ServerService/Analyze
```
```
grpcurl -plaintext localhost:8080 schema.v1.ServerService/ListIntegrations
{
"integrations": [
"trivy"
]
}
```

24
pkg/server/integration.go Normal file
View File

@@ -0,0 +1,24 @@
package server
import (
"context"
schemav1 "buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go/schema/v1"
"github.com/k8sgpt-ai/k8sgpt/pkg/integration"
)
func (*handler) ListIntegrations(ctx context.Context, req *schemav1.ListIntegrationsRequest) (*schemav1.ListIntegrationsResponse, error) {
integrationProvider := integration.NewIntegration()
integrations := integrationProvider.List()
resp := &schemav1.ListIntegrationsResponse{
Integrations: make([]string, 0),
}
for _, i := range integrations {
b, _ := integrationProvider.IsActivate(i)
if b {
resp.Integrations = append(resp.Integrations, i)
}
}
return resp, nil
}