mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
Support subpath on GET for GetterWithOptions
Allows REST consumers to build paths like: /api/v1beta3/namespaces/foo/webhookresource/<name>/<encodedsecretinurl> Also fixes parameter exposure for subresources (was only fixed for v1beta3).
This commit is contained in:
@@ -113,10 +113,19 @@ func GetResource(r rest.Getter, scope RequestScope) restful.RouteFunction {
|
||||
}
|
||||
|
||||
// GetResourceWithOptions returns a function that handles retrieving a single resource from a rest.Storage object.
|
||||
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, getOptionsKind string) restful.RouteFunction {
|
||||
func GetResourceWithOptions(r rest.GetterWithOptions, scope RequestScope, getOptionsKind string, subpath bool, subpathKey string) restful.RouteFunction {
|
||||
return getResourceHandler(scope,
|
||||
func(ctx api.Context, name string, req *restful.Request) (runtime.Object, error) {
|
||||
opts, err := queryToObject(req.Request.URL.Query(), scope, getOptionsKind)
|
||||
query := req.Request.URL.Query()
|
||||
if subpath {
|
||||
newQuery := make(url.Values)
|
||||
for k, v := range query {
|
||||
newQuery[k] = v
|
||||
}
|
||||
newQuery[subpathKey] = []string{req.PathParameter("path")}
|
||||
query = newQuery
|
||||
}
|
||||
opts, err := queryToObject(query, scope, getOptionsKind)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user