mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
K8s: Add subresource to the example apiserver (#78030)
This commit is contained in:
@@ -42,16 +42,12 @@ type APIRouteHandler struct {
|
||||
Handler http.HandlerFunc // when Level = resource, the resource will be available in context
|
||||
}
|
||||
|
||||
// APIRoutes define the
|
||||
// APIRoutes define explicit HTTP handlers in an apiserver
|
||||
// TBD: is this actually necessary -- there may be more k8s native options for this
|
||||
type APIRoutes struct {
|
||||
// Root handlers are registered directly after the apiVersion identifier
|
||||
Root []APIRouteHandler
|
||||
|
||||
// Namespace handlers are mounted under the namespace
|
||||
Namespace []APIRouteHandler
|
||||
|
||||
// Resource routes behave the same as pod/logs
|
||||
// it looks like a sub-resource, however the response is backed directly by an http handler
|
||||
// The current resource can be fetched through context
|
||||
Resource map[string]APIRouteHandler
|
||||
}
|
||||
|
||||
@@ -71,22 +71,6 @@ func getAPIHandler(delegateHandler http.Handler, restConfig *restclient.Config,
|
||||
sub.HandleFunc(route.Path, route.Handler).
|
||||
Methods(methods...)
|
||||
}
|
||||
|
||||
// getter := makeGetter(restConfig)
|
||||
for resource, route := range routes.Resource {
|
||||
err = validPath(route.Path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Printf("TODO: %s/%v\n", resource, route)
|
||||
|
||||
// get a client for that resource kind
|
||||
//getter := makeGetter(restConfig)
|
||||
|
||||
useful = true
|
||||
// sub.HandleFunc(v.Slug, SubresourceHandlerWrapper(v.Handler, getter)).
|
||||
// Methods(methods...)
|
||||
}
|
||||
}
|
||||
|
||||
if !useful {
|
||||
@@ -184,12 +168,6 @@ func getOpenAPIPostProcessor(builders []APIGroupBuilder) func(*spec3.OpenAPI) (*
|
||||
}
|
||||
}
|
||||
|
||||
for resource, route := range routes.Resource {
|
||||
copy.Paths.Paths[prefix+"/namespaces/{namespace}/"+resource+"{name}"+route.Path] = &spec3.Path{
|
||||
PathProps: *route.Spec,
|
||||
}
|
||||
}
|
||||
|
||||
return ©, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user