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