kubehook

package module
v0.3.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

kube-hook

kubernetes admission webhook framework

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Index = &index{
	v1.GroupVersionKind{
		Group:   "core",
		Version: "v1",
		Kind:    "Pods",
	}: &v12.Pod{},
}

Functions

func HandleMutatingFun

func HandleMutatingFun(f Mutatingfun) func(ctx *Ctx)

func HandleVlidatingFun

func HandleVlidatingFun(f ValidateFun) func(ctx *Ctx)

Types

type AdminMiddleWare

type AdminMiddleWare struct {
}

func (*AdminMiddleWare) Process_request

func (w *AdminMiddleWare) Process_request(ctx *Ctx)

func (*AdminMiddleWare) Process_response

func (w *AdminMiddleWare) Process_response(ctx *Ctx)

type Ctx

type Ctx struct {
	//context.WithTimeout
	context.Context
	context.CancelFunc

	Object     runtime.Object
	Old_Object runtime.Object
	Raw_Object runtime.Object

	ChangeObject runtime.Object

	Adm_obj v1.AdmissionReview

	Validate_result RST
	HandlerFunc     interface{}
	MiddlewareIndex int
	Request         *http.Request
	// contains filtered or unexported fields
}

func NewContext

func NewContext(time_out time.Duration, response http.ResponseWriter, request *http.Request) *Ctx

func (*Ctx) Cancal

func (ctx *Ctx) Cancal()

func (*Ctx) Deadline

func (ctx *Ctx) Deadline() (deadline time.Time, ok bool)

func (*Ctx) Done

func (ctx *Ctx) Done() <-chan struct{}

func (*Ctx) Err

func (ctx *Ctx) Err() error

func (*Ctx) Response

func (ctx *Ctx) Response(status_code int, body []byte)

func (*Ctx) Value

func (ctx *Ctx) Value(key interface{}) interface{}

type Hook

type Hook struct {
	HandlerFun map[string]func(ctx *Ctx)
	Middleware []MiddleWare
	// contains filtered or unexported fields
}

func Default

func Default(middlewares ...MiddleWare) *Hook

func (*Hook) HandleFun

func (h *Hook) HandleFun(ctx *Ctx) (err error)

func (*Hook) Mutating

func (h *Hook) Mutating(url string, f Mutatingfun)

func (*Hook) NextMiddleware

func (h *Hook) NextMiddleware(ctx *Ctx) (err error)

func (*Hook) Query

func (h *Hook) Query() UrlParams

func (*Hook) Registry

func (h *Hook) Registry(kind metav1.GroupVersionKind, resource runtime.Object)

func (*Hook) Route

func (h *Hook) Route(url string, f func(ctx *Ctx))

func (*Hook) Run

func (h *Hook) Run(addr, certFile, keyFile string)

func (*Hook) ServeHTTP

func (h *Hook) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Hook) Validating

func (h *Hook) Validating(url string, f ValidateFun)

type MiddleWare

type MiddleWare interface {
	Process_request(ctx *Ctx)

	Process_response(ctx *Ctx)
}

type Mutatingfun

type Mutatingfun func(obj runtime.Object) runtime.Object

type RST

type RST struct {
	Code    int32
	Message string
	Result  bool
}

type Reponse

type Reponse struct {
	http.ResponseWriter
	StatuCode int
	// contains filtered or unexported fields
}

func (*Reponse) WriteReponse

func (res *Reponse) WriteReponse(data []byte, StatuCode int) (int, error)

type ResourceHook

type ResourceHook interface {
	ValidateCreate(obj runtime.Object) RST
	ValidateUpdate(obj, old_obj runtime.Object) RST
	ValidateDelete(obj runtime.Object) RST
}

type ResourceMiddleWare

type ResourceMiddleWare struct {
}

func (*ResourceMiddleWare) Process_request

func (w *ResourceMiddleWare) Process_request(ctx *Ctx)

func (*ResourceMiddleWare) Process_response

func (w *ResourceMiddleWare) Process_response(ctx *Ctx)

type TypeError

type TypeError struct {
	Message string
}

func (*TypeError) Error

func (err *TypeError) Error() string

func (*TypeError) String

func (err *TypeError) String() string

type UrlParams

type UrlParams map[string]string

type ValidateFun

type ValidateFun struct {
	ValidateUpdate func(obj, old_obj runtime.Object) RST
	ValidateDelete func(obj runtime.Object) RST
	ValidateCreate func(obj runtime.Object) RST
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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