base

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName = "ceems_k8s_admission_controller"
)

Variables

This section is empty.

Functions

func NewDecoder

func NewDecoder() (runtime.Decoder, error)

NewDecoder returns a new decoder for deserializing requests.

func NewRuntimeScheme

func NewRuntimeScheme() (*runtime.Scheme, error)

NewRuntimeScheme returns new runtime scheme with all necessary resources added.

Types

type AdmitFunc

type AdmitFunc func(request *admissionv1.AdmissionRequest, decoder runtime.Decoder, logger *slog.Logger) (*Result, error)

AdmitFunc defines how to process an admission request.

type Config

type Config struct {
	Logger *slog.Logger
	Web    WebConfig
}

Config makes a server config.

type Hook

type Hook struct {
	Create  AdmitFunc
	Delete  AdmitFunc
	Update  AdmitFunc
	Connect AdmitFunc
}

Hook represents the set of functions for each operation in an admission webhook.

func (*Hook) Execute

Execute evaluates the request and try to execute the function for operation specified in the request.

type PatchOperation

type PatchOperation struct {
	Op    string `json:"op"`
	Path  string `json:"path"`
	From  string `json:"from"`
	Value any    `json:"value,omitempty"`
}

PatchOperation is an operation of a JSON patch https://tools.ietf.org/html/rfc6902.

func AddPatchOperation

func AddPatchOperation(path string, value any) PatchOperation

AddPatchOperation returns an add JSON patch operation.

func CopyPatchOperation

func CopyPatchOperation(from, path string) PatchOperation

CopyPatchOperation returns a copy JSON patch operation.

func MovePatchOperation

func MovePatchOperation(from, path string) PatchOperation

MovePatchOperation returns a move JSON patch operation.

func RemovePatchOperation

func RemovePatchOperation(path string) PatchOperation

RemovePatchOperation returns a remove JSON patch operation.

func ReplacePatchOperation

func ReplacePatchOperation(path string, value any) PatchOperation

ReplacePatchOperation returns a replace JSON patch operation.

type Result

type Result struct {
	Allowed  bool
	Msg      string
	PatchOps []PatchOperation
}

Result contains the result of an admission request.

type WebConfig

type WebConfig struct {
	Addresses         []string
	WebSystemdSocket  bool
	WebConfigFile     string
	EnableDebugServer bool
}

WebConfig makes HTTP web config from CLI args.

Jump to

Keyboard shortcuts

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