custom

package
v1.19.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RequestFailedCode starting code for error response
	RequestFailedCode = 4001
	// RequestSuccessCode code for success
	RequestSuccessCode = 0
)

Variables

View Source
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

func CustomServerErrorResponse(response *restful.Response, msg string)

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

func CustomSuccessResponse(response *restful.Response, msg string, data interface{})

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 NewRouter

func NewRouter() (ar *APIRouter)

NewRouter implementation creator

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 APIUrl

type APIUrl string

APIUrl url for

type BcsClientAPIHandler

type BcsClientAPIHandler struct {
	KubeMasterUrl string
	TLSConfig     options.TLSConfig
}

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

func (*ClusterResourceAPIHandler) Handler

func (cph *ClusterResourceAPIHandler) Handler(request *restful.Request, response *restful.Response)

Handler handle http request

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

func (*ClusterStatusAPIHandler) Config

func (csh *ClusterStatusAPIHandler) Config(KubeMasterURL string, TLSConfig options.TLSConfig) error

Config config kube clientset

func (*ClusterStatusAPIHandler) Handler

func (csh *ClusterStatusAPIHandler) Handler(request *restful.Request, response *restful.Response)

Handler http implementation

type ResourceStatus

type ResourceStatus struct {
	Cpu    float64
	Memory float64
}

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) Payload

func (n *ServiceNode) Payload() []byte

Payload content length

func (*ServiceNode) PrimaryKey

func (n *ServiceNode) PrimaryKey() string

PrimaryKey key for indexer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL