Documentation ¶
Index ¶
- Constants
- Variables
- func CustomHTTPResponse(response *restful.Response, httpCode int, result bool, msg string, code int, ...)
- func CustomServerErrorResponse(response *restful.Response, msg string)
- func CustomSimpleHTTPResponse(response *restful.Response, httpCode int, resp APIResponse)
- func CustomSuccessResponse(response *restful.Response, msg string, data interface{})
- func PodRequestsAndLimits(pod *v1.Pod) (reqs map[v1.ResourceName]resource.Quantity, ...)
- type APIHandler
- type APIResponse
- type APIRouter
- type APIRouterInterface
- type APIUrl
- type BcsClientAPIHandler
- type ClusterResourceAPIHandler
- type ClusterResourceStatus
- type ClusterStatusAPIHandler
- type ResourceStatus
- type ServiceNode
Constants ¶
const ( // RequestFailedCode starting code for error response RequestFailedCode = 4001 // RequestSuccessCode code for success RequestSuccessCode = 0 )
Variables ¶
var UrlHandlerMap = map[string]APIHandler{ "cluster/resources": &ClusterResourceAPIHandler{}, "bcsclient/.+": &BcsClientAPIHandler{}, }
UrlHandlerMap key can't be same with K8S URI Warning: It can not be start with "api" or "apis"
Functions ¶
func CustomHTTPResponse ¶
func CustomHTTPResponse(response *restful.Response, httpCode int, result bool, msg string, code int, data interface{})
CustomHTTPResponse : custom http response
func CustomServerErrorResponse ¶
CustomServerErrorResponse : custom http response for inner server error
func CustomSimpleHTTPResponse ¶
func CustomSimpleHTTPResponse(response *restful.Response, httpCode int, resp APIResponse)
CustomSimpleHTTPResponse : simple http response
func CustomSuccessResponse ¶
CustomSuccessResponse : custom http response for success
func PodRequestsAndLimits ¶
func PodRequestsAndLimits(pod *v1.Pod) (reqs map[v1.ResourceName]resource.Quantity, limits map[v1.ResourceName]resource.Quantity)
PodRequestsAndLimits parse pod request & limit resource
Types ¶
type APIHandler ¶
type APIHandler interface { Handler(request *restful.Request, response *restful.Response) Config(KubeMasterURL string, TLSConfig options.TLSConfig) error }
APIHandler http API interface for info request
type APIResponse ¶
type APIResponse struct { Result bool `json:"result"` Message string `json:"message"` Code int `json:"code"` Data interface{} `json:"data"` }
APIResponse common http response
type APIRouter ¶
type APIRouter struct {
UrlHandlerMap map[string]APIHandler
}
APIRouter implementation
func (*APIRouter) InitRegisteredUrls ¶
func (ar *APIRouter) InitRegisteredUrls()
InitRegisteredUrls init URL
func (*APIRouter) Route ¶
func (ar *APIRouter) Route(subPath string) (handler APIHandler)
Route http url request route
type APIRouterInterface ¶
type APIRouterInterface interface {
Route(subPath string) *APIHandler
}
APIRouterInterface interface for http request route
type BcsClientAPIHandler ¶
func (*BcsClientAPIHandler) Config ¶
func (h *BcsClientAPIHandler) Config(KubeMasterURL string, TLSConfig options.TLSConfig) error
func (*BcsClientAPIHandler) Handler ¶
func (h *BcsClientAPIHandler) Handler(request *restful.Request, response *restful.Response)
func (*BcsClientAPIHandler) IfKubeNeedTls ¶
func (h *BcsClientAPIHandler) IfKubeNeedTls() bool
type ClusterResourceAPIHandler ¶
type ClusterResourceAPIHandler struct {
// contains filtered or unexported fields
}
ClusterResourceAPIHandler http implementation
func (*ClusterResourceAPIHandler) Config ¶
func (cph *ClusterResourceAPIHandler) Config(KubeMasterURL string, TLSConfig options.TLSConfig) error
Config config kube clientset
func (*ClusterResourceAPIHandler) FetchAllPods ¶
func (cph *ClusterResourceAPIHandler) FetchAllPods() (allPodsInNode *v1.PodList)
FetchAllPods list all pod from kube-apiserver
type ClusterResourceStatus ¶
type ClusterResourceStatus struct { Capacity ResourceStatus Limit ResourceStatus Request ResourceStatus }
ClusterResourceStatus all kind resource
type ClusterStatusAPIHandler ¶
type ClusterStatusAPIHandler struct {
// contains filtered or unexported fields
}
ClusterStatusAPIHandler cluster node http api implementation
type ResourceStatus ¶
ResourceStatus status of request resources
type ServiceNode ¶
type ServiceNode types.ServerInfo
ServiceNode is node info for bcs services.
func NewServiceNode ¶
func NewServiceNode(info types.ServerInfo) ServiceNode
NewServiceNode create kubedriver service node
func (*ServiceNode) OwnsPayload ¶
func (n *ServiceNode) OwnsPayload(payload []byte) bool
OwnsPayload xxxx
func (*ServiceNode) PrimaryKey ¶
func (n *ServiceNode) PrimaryKey() string
PrimaryKey key for indexer