1
0
mirror of https://github.com/rancher/steve.git synced 2025-04-27 02:51:10 +00:00
steve/pkg/server/handler/handlers.go
Michael Bolot b73cc57b20 Adding validate phase to the CI
Adds a validate phase to the CI which runs a linter. Also fixes
linter issues discovered during the initial run
2022-10-14 15:21:17 -05:00

33 lines
701 B
Go

package handler
import (
"github.com/gorilla/mux"
"github.com/rancher/apiserver/pkg/types"
"github.com/rancher/steve/pkg/attributes"
"github.com/rancher/steve/pkg/schema"
)
func k8sAPI(sf schema.Factory, apiOp *types.APIRequest) {
vars := mux.Vars(apiOp.Request)
apiOp.Name = vars["name"]
apiOp.Type = vars["type"]
nOrN := vars["nameorns"]
if nOrN != "" {
schema := apiOp.Schemas.LookupSchema(apiOp.Type)
if attributes.Namespaced(schema) {
vars["namespace"] = nOrN
} else {
vars["name"] = nOrN
}
}
if namespace := vars["namespace"]; namespace != "" {
apiOp.Namespace = namespace
}
}
func apiRoot(sf schema.Factory, apiOp *types.APIRequest) {
apiOp.Type = "apiRoot"
}