From e5e613acee0a99f108dd90affc55a18dee42ad9c Mon Sep 17 00:00:00 2001 From: Matthis <99146727+matthisholleville@users.noreply.github.com> Date: Sun, 14 May 2023 11:07:43 +0200 Subject: [PATCH] feat: filters api (#407) * fix: stop execution after matching condition in RunAnalysis() The commit fixes the issue where the RunAnalysis() function continues execution even after matching a condition. The fix ensures that the execution stops at the end of the corresponding if statement, improving the control flow and preventing unnecessary processing. Signed-off-by: Matthis Holleville * feat: include filters parameter in AnalyzeRequest initialization The commit introduces a new feature where the filters parameter is included in the initialization of the AnalyzeRequest. This enhancement allows for more specific analysis by specifying filters during the analysis process. Signed-off-by: Matthis Holleville --------- Signed-off-by: Matthis Holleville --- go.mod | 4 ++-- go.sum | 10 +++++----- pkg/analysis/analysis.go | 2 ++ pkg/server/handler.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index b93347c5c3..a6d397ca93 100644 --- a/go.mod +++ b/go.mod @@ -24,8 +24,8 @@ require ( require github.com/adrg/xdg v0.4.0 require ( - buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230506120742-576a6b5d0a86.1 - buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230510140658-54288a50e81c.4 + buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230514071713-3d78cb8bbc06.1 + buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.30.0-20230514071713-3d78cb8bbc06.1 ) require ( diff --git a/go.sum b/go.sum index 4e30c28281..232b55555e 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230506120742-576a6b5d0a86.1 h1:PQaEhu0fgP6BP2WciRwe9ol9ChEyO7U/lCiHYlwYxRM= -buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230506120742-576a6b5d0a86.1/go.mod h1:hNUyDnPCFDSlQTEVED8xxZV0WXRcElFSM+LLLbP7zCQ= -buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230506120742-576a6b5d0a86.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE= -buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230510140658-54288a50e81c.4 h1:gcv6/jWv+qlehnaqHIjppNqQiHojZDDvs+NOGkxAUq8= -buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230510140658-54288a50e81c.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE= +buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230514071713-3d78cb8bbc06.1 h1:uu6has8/9E3yVp77PJ/uDsgqhJemqvdfxPFv+pwhQ8M= +buf.build/gen/go/k8sgpt-ai/k8sgpt/grpc/go v1.3.0-20230514071713-3d78cb8bbc06.1/go.mod h1:P+Ze553ll8pj8fJatVJw077ODiymvZXai4uayYu7e7M= +buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.28.1-20230514071713-3d78cb8bbc06.4/go.mod h1:i/s4ALHwKvjA1oGNKpoHg0FpEOTbufoOm/NdTE6YQAE= +buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.30.0-20230514071713-3d78cb8bbc06.1 h1:V43+hDZXo4WaGqGZjNfaL8ZcAEvhusckIC/JBD/msz0= +buf.build/gen/go/k8sgpt-ai/k8sgpt/protocolbuffers/go v1.30.0-20230514071713-3d78cb8bbc06.1/go.mod h1:karV92RruD5davytOQq20lDyAqBnai8ajNolo98nu94= 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= diff --git a/pkg/analysis/analysis.go b/pkg/analysis/analysis.go index e19920146d..b9f8ca5b42 100644 --- a/pkg/analysis/analysis.go +++ b/pkg/analysis/analysis.go @@ -152,6 +152,7 @@ func (a *Analysis) RunAnalysis() { } wg.Wait() + return } semaphore = make(chan struct{}, a.MaxConcurrency) // if the filters flag is specified @@ -180,6 +181,7 @@ func (a *Analysis) RunAnalysis() { } } wg.Wait() + return } var wg sync.WaitGroup diff --git a/pkg/server/handler.go b/pkg/server/handler.go index cfa3b15d4e..9f685fc2e9 100644 --- a/pkg/server/handler.go +++ b/pkg/server/handler.go @@ -32,7 +32,7 @@ func (h *handler) Analyze(ctx context.Context, i *schemav1.AnalyzeRequest) ( config, err := analysis.NewAnalysis( i.Backend, i.Language, - []string{}, + i.Filters, i.Namespace, i.Nocache, i.Explain,