admission

package
v0.0.0-...-64e8fac Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 18 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 DummyValidatingWebhookServer

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

func NewDummyWebhookServer

func NewDummyWebhookServer() *DummyValidatingWebhookServer

NewDummyWebhookServer creates a dummy validating webhook server for testing

func (*DummyValidatingWebhookServer) ReadAndResponse

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

func (*DummyValidatingWebhookServer) Stop

func (w *DummyValidatingWebhookServer) Stop()

func (*DummyValidatingWebhookServer) Validating

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

func (*DummyValidatingWebhookServer) ValidatingURL

func (w *DummyValidatingWebhookServer) 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"`
}

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"`
}

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