sting

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2022 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Schemas, codecs etc. so serialize and deserialize datatypes for Kubernetes

View Source
var Version = "unset"
View Source
var (
	// WrongResourceError can be used to indicate that this webhook doesn't support this resource-
	// This might happen due to wrong configuration etc.
	WrongResourceError = errors.New("Wrong resource type")
)

Functions

func AnnotationHasValue

func AnnotationHasValue(obj runtime.Object, key, val string) bool

AnnotationHasValue checks whether an API object has annotations and these annotations contain the specified key with the specified value

func AnnotationValue

func AnnotationValue(obj runtime.Object, key string, def ...string) string

AnnotationValue retrieves the string representation of the value of an annotation specified by key. In case the annotation is not found a default value can be specified as the last parameter

func CreatePatch

func CreatePatch(mutatedObj runtime.Object, objRaw []byte) ([]byte, error)

CreatePatch creates a JSON patch from the given mutatedObj and its JSON serialized original structure.

func Main

func Main(closeable io.Closer)

Main is a simple helper method which takes an io.Closer and blocks until either SIGTERM oder SIGINT are received and the calls Close() in the io.Closer() and exits with (0)

func ToAdmissionResponse

func ToAdmissionResponse(err error) *v1beta1.AdmissionResponse

ToAdmissionResponse is a simple method to create a v1beta1.AdmissionResponse struct with an error message set

Types

type InjectServer

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

InjectServer is an opinionated implementation of a service running within kubernetes as admission webhook. It provides a HTTPS secured endpoint for admission/mutation and a HTTP endpoint for readiness and liveness checks

func New

func New(opts *Options) (*InjectServer, error)

New creates and starts a new InjectServer. InjectServer implements io.Closer so it can be used together with the helper function Main

func (*InjectServer) Close

func (i *InjectServer) Close() error

Close is necessary to implement io.Closer interface

type IsAdmittedFunc

type IsAdmittedFunc func(ar *v1beta1.AdmissionReview) (*v1beta1.AdmissionResponse, error)

IsAdmittedFunc is used for admitting only webhooks to determine wether a resource can be admitted

type MutateFunc

type MutateFunc func(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionResponse

MutateFunc is the definition for functions doing the mutation of a resource

type NeedsMutationFunc

type NeedsMutationFunc func(ar *v1beta1.AdmissionReview) bool

NeedsMutationFunc can be used to run more complex checks before MutateFunc is called

type Options

type Options struct {
	// ListenAddr is used for the admission endpoint. Default is :443
	ListenAddr string
	// The function implementation to be used when running mutations.
	Mutate MutateFunc
	// Optional function to be used to decide whether a mutation is necessary or not
	NeedsMutate NeedsMutationFunc
	// IsAdmitted can be set to enable admission checks
	IsAdmitted IsAdmittedFunc

	// These are parameters for the HTTP(S) server, they are optional and default to sane values
	ReadTimeout       time.Duration
	IdleTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration

	// Path to the server X.509 certificate
	CertFile string
	// Path to the server private key
	KeyFile string
	// Unused so far. Will be required for support of TLS authenticated clients
	CaFile string
	// contains filtered or unexported fields
}

Options are used to configure the InjectServer

func NewOptions

func NewOptions() *Options

NewOptions creates a new instance of an Options struct with sane values set. Only Mutate, NeedsMutate or IsAdmitted need to set now.

Jump to

Keyboard shortcuts

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