Skip to content

Commit

Permalink
feat: lists activate integrations (#669)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
AlexsJones committed Sep 19, 2023
1 parent d6b7b81 commit 844ff1f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down
9 changes: 9 additions & 0 deletions pkg/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 24 additions & 0 deletions pkg/server/integration.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 844ff1f

Please sign in to comment.