affinityinjector

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package affinityinjector deals with AdmissionReview requests and responses

Index

Constants

View Source
const (
	CreateAffinity              = "/spec/affinity"
	CreateNodeAffinity          = "/spec/affinity/nodeAffinity"
	AddRequiredDuringScheduling = "/spec/affinity/nodeAffinity/requiredDuringSchedulingIgnoredDuringExecution"
	AddNodeSelectorTerms        = "/spec/affinity/nodeAffinity/requiredDuringSchedulingIgnoredDuringExecution/nodeSelectorTerms/-"
)

AffinityPath values

Variables

View Source
var (
	ErrInvalidAdmissionReview        = errors.New("invalid admission review")
	ErrInvalidAdmissionReviewObj     = errors.New("invalid admission review object")
	ErrFailedToCreatePatch           = errors.New("failed to create patch")
	ErrFailedToReadNodeSelectorTerms = errors.New("failed to load node selector terms")
	ErrMissingConfiguration          = errors.New("missing configuration")
	ErrMissingNodeSelectorTerms      = errors.New("missing nodeSelectorTerms from config")
	ErrInvalidConfiguration          = errors.New("invalid configuration")
)

Errors returned by this package

Functions

This section is empty.

Types

type AffinityInjector

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

AffinityInjector handles AdmissionReview objects

func NewAffinityInjector

func NewAffinityInjector(k8sclient k8sclient.Interface, configMapName string) *AffinityInjector

NewAffinityInjector returns *AffinityInjector with k8sclient and configMapName

func (*AffinityInjector) Mutate

func (m *AffinityInjector) Mutate(body []byte) ([]byte, error)

Mutate unmarshalls the AdmissionReview (body) and creates or updates the nodeAffinity of the k8s object in the admission review request, sets the AdmissionReview response and returns the marshalled AdmissionReview or an error

type AffinityPath

type AffinityPath string

AffinityPath is the path for the JSON patch

type JSONPatch

type JSONPatch struct {
	Op    string       `json:"op"`
	Path  AffinityPath `json:"path"`
	Value interface{}  `json:"value"`
}

JSONPatch is the JSON patch (http://jsonpatch.com) for patching k8s object

Jump to

Keyboard shortcuts

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