interpreter

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectDecoderInto

func InjectDecoderInto(decoder *Decoder, i interface{}) bool

InjectDecoderInto will set decoder on i and return the result if it implements Decoder. Returns false if i does not implement Decoder.

Types

type Decoder

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

Decoder knows how to decode the contents of an resource interpreter request into a concrete object.

func NewDecoder

func NewDecoder(scheme *runtime.Scheme) *Decoder

NewDecoder creates a Decoder given the runtime.Scheme.

func (*Decoder) Decode

func (d *Decoder) Decode(req Request, into runtime.Object) error

Decode decodes the inlined object in the ResourceInterpreterRequest into the passed-in runtime.Object. If you want to decode the ObservedObject in the ResourceInterpreterRequest, use DecodeRaw. It errors out if req.Object.Raw is empty i.e. containing 0 raw bytes.

func (*Decoder) DecodeRaw

func (d *Decoder) DecodeRaw(rawObj runtime.RawExtension, into runtime.Object) error

DecodeRaw decodes a RawExtension object into the passed-in runtime.Object. It errors out if rawObj is empty i.e. containing 0 raw bytes.

type DecoderInjector

type DecoderInjector interface {
	InjectDecoder(*Decoder)
}

DecoderInjector is used by the ControllerManager to inject decoder into webhook handlers.

type Handler

type Handler interface {
	// Handle yields a response to an ResourceInterpreterRequest.
	//
	// The supplied context is extracted from the received http.Request, allowing wrapping
	// http.Handlers to inject values into and control cancellation of downstream request processing.
	Handle(context.Context, Request) Response
}

Handler can handle an ResourceInterpreterRequest.

type Request

type Request struct {
	configv1alpha1.ResourceInterpreterRequest
}

Request defines the input for an interpreter handler. It contains information to identify the object in question (kind, name, namespace), as well as the operation in request(e.g. InterpreterOperationInterpretReplica, InterpreterOperationPrune, etc), and the object itself.

type Response

type Response struct {
	configv1alpha1.ResourceInterpreterResponse
}

Response is the output of an interpreter handler.

func Errored

func Errored(code int32, err error) Response

Errored creates a new Response for error-handling a request.

func PatchResponseFromRaw

func PatchResponseFromRaw(original, current []byte) Response

PatchResponseFromRaw takes 2 byte arrays and returns a new response with patch.

func Succeeded

func Succeeded(msg string) Response

Succeeded constructs a response indicating the given operation is handled successfully.

func ValidationResponse

func ValidationResponse(successful bool, msg string) Response

ValidationResponse returns a response for handle a interpret request.

func (*Response) Complete

func (r *Response) Complete(req Request)

Complete populates any fields that are yet to be set in the underlying ResourceInterpreterResponse, It mutates the response.

type Webhook

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

Webhook represents each individual webhook.

func NewWebhook

func NewWebhook(handler Handler, decoder *Decoder) *Webhook

NewWebhook return a Webhook

func (*Webhook) Handle

func (wh *Webhook) Handle(ctx context.Context, req Request) Response

Handle processes ResourceInterpreterRequest.

func (*Webhook) ServeHTTP

func (wh *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP write reply headers and data to the ResponseWriter and then return.

Jump to

Keyboard shortcuts

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