Documentation
¶
Index ¶
- Variables
- func Authenticate(req *http.Request) bool
- func CreateResponeData(err error, msg string, data interface{}) string
- func NewForbidden(qualifiedResource schema.GroupResource, name string, err error) *errors.StatusError
- func NewInternalError(err error) *errors.StatusError
- func NewInvalid(qualifiedKind schema.GroupKind, name string, fieldName string, err error) *errors.StatusError
- func NewNotFound(qualifiedResource schema.GroupResource, name string, message string) *errors.StatusError
- func NewUnauthorized(reason string) *errors.StatusError
- func ValidateAPIServerAddresses(fl validator.FieldLevel) bool
- func WriteFuncFactory(statusCode int) func(response *restful.Response, code int, message string)
- func WriteKubeAPIError(rw http.ResponseWriter, err *errors.StatusError)
- type EmptyResponse
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
var ClusterGroupKind = v1.Kind("Cluster")
var ClusterResource = v1.Resource("Clusters")
var Validate = validator.New()
var WriteClientError = WriteFuncFactory(400)
var WriteForbiddenError = WriteFuncFactory(403)
var WriteNotFoundError = WriteFuncFactory(404)
var WriteServerError = WriteFuncFactory(500)
Functions ¶
func Authenticate ¶
Authenticate only authenticate admin user token
func CreateResponeData ¶
func NewForbidden ¶
func NewForbidden(qualifiedResource schema.GroupResource, name string, err error) *errors.StatusError
func NewInternalError ¶
func NewInternalError(err error) *errors.StatusError
func NewInvalid ¶
func NewInvalid(qualifiedKind schema.GroupKind, name string, fieldName string, err error) *errors.StatusError
NewInvalid returns an error indicating the item is invalid and cannot be processed.
func NewNotFound ¶
func NewNotFound(qualifiedResource schema.GroupResource, name string, message string) *errors.StatusError
NewNotFound returns a new error which indicates that the resource of the kind and the name was not found.
func NewUnauthorized ¶
func NewUnauthorized(reason string) *errors.StatusError
NewUnauthorized returns an error indicating the client is not authorized to perform the requested action.
func ValidateAPIServerAddresses ¶
func ValidateAPIServerAddresses(fl validator.FieldLevel) bool
ValidateAPIServerAddresses validates if given string is a valid apiserver addresses list. A valid addresses should be a list of URL concated with ';'
func WriteFuncFactory ¶
WriteFuncFactory builds WriteXXX shortcut functions
func WriteKubeAPIError ¶
func WriteKubeAPIError(rw http.ResponseWriter, err *errors.StatusError)
WriteKubeAPIError writes a standard error response
Types ¶
type EmptyResponse ¶
type EmptyResponse struct{}
type ErrorResponse ¶
type ErrorResponse struct { Result bool `json:"result"` Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
func FormatValidationError ¶
func FormatValidationError(errList error) *ErrorResponse
FormatValidationError turn the original validatetion errors into error response, it will only use the FIRST errorField to construct the error message.