1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-27 11:00:48 +00:00
steve/pkg/server/handler/handlers.go

33 lines
701 B
Go
Raw Normal View History

2020-01-31 05:37:59 +00:00
package handler
2019-08-14 18:08:34 +00:00
import (
"github.com/gorilla/mux"
"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"]
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"
}