Scopes: Add a /find query endpoint (#87457)

---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Todd Treece
2024-05-08 13:35:11 -04:00
committed by GitHub
parent 01d28e01d2
commit 6e4d35e1ee
10 changed files with 422 additions and 68 deletions
+12
View File
@@ -3,6 +3,7 @@ package builder
import (
"fmt"
"net/http"
"regexp"
goruntime "runtime"
"runtime/debug"
"strconv"
@@ -25,6 +26,16 @@ import (
"github.com/grafana/grafana/pkg/apiserver/endpoints/filters"
)
var pathRewriters = []filters.PathRewriter{
{
// TODO: this is a temporary hack to make rest.Connecter work with resource level routes
Pattern: regexp.MustCompile(`(/apis/scope.grafana.app/v0alpha1/namespaces/.*/find$)`),
ReplaceFunc: func(matches []string) string {
return matches[1] + "/name" // connector requires a name
},
},
}
func SetupConfig(
scheme *runtime.Scheme,
serverConfig *genericapiserver.RecommendedConfig,
@@ -76,6 +87,7 @@ func SetupConfig(
handler := genericapiserver.DefaultBuildHandlerChain(requestHandler, c)
handler = filters.WithAcceptHeader(handler)
handler = filters.WithPathRewriters(handler, pathRewriters)
handler = k8stracing.WithTracing(handler, serverConfig.TracerProvider, "KubernetesAPI")
return handler