2020-01-31 05:37:59 +00:00
|
|
|
package handler
|
2019-08-14 18:08:34 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gorilla/mux"
|
2020-06-12 04:50:59 +00:00
|
|
|
"github.com/rancher/apiserver/pkg/types"
|
2019-09-11 21:05:00 +00:00
|
|
|
"github.com/rancher/steve/pkg/attributes"
|
2020-01-31 05:37:59 +00:00
|
|
|
"github.com/rancher/steve/pkg/schema"
|
2019-08-14 18:08:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
|
|
|
|
vars := mux.Vars(apiOp.Request)
|
|
|
|
apiOp.Name = vars["name"]
|
2020-03-11 06:12:04 +00:00
|
|
|
apiOp.Type = vars["type"]
|
2019-08-14 18:08:34 +00:00
|
|
|
|
|
|
|
nOrN := vars["nameorns"]
|
|
|
|
if nOrN != "" {
|
2020-01-31 05:37:59 +00:00
|
|
|
schema := apiOp.Schemas.LookupSchema(apiOp.Type)
|
2019-08-14 18:08:34 +00:00
|
|
|
if attributes.Namespaced(schema) {
|
|
|
|
vars["namespace"] = nOrN
|
|
|
|
} else {
|
|
|
|
vars["name"] = nOrN
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if namespace := vars["namespace"]; namespace != "" {
|
2020-01-31 05:37:59 +00:00
|
|
|
apiOp.Namespace = namespace
|
2019-08-14 18:08:34 +00:00
|
|
|
}
|
|
|
|
}
|
2019-08-14 20:39:08 +00:00
|
|
|
|
|
|
|
func apiRoot(sf schema.Factory, apiOp *types.APIRequest) {
|
|
|
|
apiOp.Type = "apiRoot"
|
|
|
|
}
|