admission

package
v0.0.0-...-d125d34 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 5 * time.Second

Variables

This section is empty.

Functions

func NewHTTPWebhooks

func NewHTTPWebhooks(config config.Admission)

NewHTTPWebhooks registers the webhooks

func Register

func Register(kind models.Kind, webhook Webhook)

func Validating

func Validating(ctx context.Context, request *Request) error

Types

type DummyWebhookServer

type DummyWebhookServer struct {
	// contains filtered or unexported fields
}

func NewDummyWebhookServer

func NewDummyWebhookServer() *DummyWebhookServer

NewDummyWebhookServer creates a dummy validating webhook server for testing

func (*DummyWebhookServer) Mutating

func (w *DummyWebhookServer) Mutating(resp http.ResponseWriter, req *http.Request)

func (*DummyWebhookServer) MutatingURL

func (w *DummyWebhookServer) MutatingURL() string

func (*DummyWebhookServer) ReadAndResponse

func (*DummyWebhookServer) ReadAndResponse(resp http.ResponseWriter,
	req *http.Request, fn func(Request, *Response))

func (*DummyWebhookServer) Stop

func (w *DummyWebhookServer) Stop()

func (*DummyWebhookServer) Validating

func (w *DummyWebhookServer) Validating(resp http.ResponseWriter, req *http.Request)

func (*DummyWebhookServer) ValidatingURL

func (w *DummyWebhookServer) ValidatingURL() string

type HTTPAdmissionClient

type HTTPAdmissionClient struct {
	http.Client
	// contains filtered or unexported fields
}

func NewHTTPAdmissionClient

func NewHTTPAdmissionClient(config config.ClientConfig, timeout time.Duration) *HTTPAdmissionClient

NewHTTPAdmissionClient creates a new HTTPAdmissionClient

func (*HTTPAdmissionClient) Get

func (c *HTTPAdmissionClient) Get(ctx context.Context, admitData *Request) (*Response, error)

Get sends the admission request to the webhook server and returns the response

type HTTPAdmissionWebhook

type HTTPAdmissionWebhook struct {
	// contains filtered or unexported fields
}

func (*HTTPAdmissionWebhook) Handle

func (m *HTTPAdmissionWebhook) Handle(ctx context.Context, req *Request) (*Response, error)

Handle handles the admission request and returns the response

func (*HTTPAdmissionWebhook) IgnoreError

func (m *HTTPAdmissionWebhook) IgnoreError() bool

IgnoreError returns true if the webhook is allowed to ignore the error

func (*HTTPAdmissionWebhook) Interest

func (m *HTTPAdmissionWebhook) Interest(req *Request) bool

Interest returns true if the request matches the webhook

type Request

type Request struct {
	Operation   models.Operation       `json:"operation"`
	Resource    string                 `json:"resource"`
	Name        string                 `json:"name"`
	SubResource string                 `json:"subResource"`
	Version     string                 `json:"version"`
	Object      interface{}            `json:"object"`
	OldObject   interface{}            `json:"oldObject"`
	Options     map[string]interface{} `json:"options,omitempty"`
}

func Mutating

func Mutating(ctx context.Context, request *Request) (*Request, error)

type ResourceMatcher

type ResourceMatcher struct {
	// contains filtered or unexported fields
}

func NewResourceMatcher

func NewResourceMatcher(rule config.Rule) *ResourceMatcher

NewResourceMatcher creates a new ResourceMatcher

func (*ResourceMatcher) Match

func (m *ResourceMatcher) Match(req *Request) bool

Match returns true if the request matches the matcher

type ResourceMatchers

type ResourceMatchers []*ResourceMatcher

func NewResourceMatchers

func NewResourceMatchers(rules []config.Rule) ResourceMatchers

NewResourceMatchers creates a new ResourceMatchers

func (ResourceMatchers) Match

func (m ResourceMatchers) Match(req *Request) bool

Match returns true if any matcher matches the request

type Response

type Response struct {
	Allowed   *bool  `json:"allowed"`
	Result    string `json:"result,omitempty"`
	Patch     []byte `json:"patch,omitempty"`
	PatchType string `json:"patchType,omitempty"`
}

type Webhook

type Webhook interface {
	Handle(context.Context, *Request) (*Response, error)
	IgnoreError() bool
	Interest(*Request) bool
}

func NewHTTPWebhook

func NewHTTPWebhook(config config.Webhook) Webhook

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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