-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial integration support (#225)
* feat: initial integration support Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: added timeout Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: added timeout Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: wip Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: wip Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated rbac Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: updated schema dependencies Signed-off-by: Alex Jones <alexsimonjones@gmail.com> * chore: resolved mod issues Signed-off-by: Alex Jones <alexsimonjones@gmail.com> --------- Signed-off-by: Alex Jones <alexsimonjones@gmail.com>
- Loading branch information
1 parent
8373b8a
commit 246077e
Showing
13 changed files
with
147 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
rpc "buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go/schema/v1/schemav1grpc" | ||
schemav1 "buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go/schema/v1" | ||
"github.com/k8sgpt-ai/k8sgpt-operator/api/v1alpha1" | ||
) | ||
|
||
func (c *Client) AddIntegration(config *v1alpha1.K8sGPT) error { | ||
|
||
// Check if the integration is active already | ||
client := rpc.NewServerServiceClient(c.conn) | ||
req := &schemav1.ListIntegrationsRequest{} | ||
|
||
resp, err := client.ListIntegrations(context.Background(), | ||
req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if resp.Trivy.Enabled == config.Spec.Integrations.Trivy.Enabled { | ||
fmt.Println("Skipping trivy installation, already enabled") | ||
return nil | ||
} | ||
// If the integration is inactive, make it active | ||
// Equally, if the flag has been deactivated we should also account for this | ||
// TODO: Currently this only support trivy | ||
configUpdatereq := &schemav1.AddConfigRequest{ | ||
Integrations: &schemav1.Integrations{ | ||
Trivy: &schemav1.Trivy{ | ||
Enabled: config.Spec.Integrations.Trivy.Enabled, | ||
SkipInstall: config.Spec.Integrations.Trivy.SkipInstall, | ||
Namespace: config.Spec.Integrations.Trivy.Namespace, | ||
}, | ||
}, | ||
} | ||
_, err = client.AddConfig(context.Background(), configUpdatereq) | ||
if err != nil { | ||
return fmt.Errorf("failed to call AddConfig RPC: %v", err) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters