Scopes: Add a /find query endpoint (#87457)
--------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user