utils

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrDecodeRequestObject indicates an error in decoding the request object.
	ErrDecodeRequestObject = "ERR_DECODE_REQUEST_OBJECT"
	// ErrGetStatefulSet indicates an error in fetching the StatefulSet resource.
	ErrGetStatefulSet = "ERR_GET_SCALE_SUBRESOURCE_PARENT"
	// ErrTooManyMatchingStatefulSets indicates that more than one StatefulSet was found for the given labels.
	ErrTooManyMatchingStatefulSets = "ERR_TOO_MANY_MATCHING_STATEFULSETS"
)
View Source
const (
	// ServiceAccountUsernamePrefix is the service account username prefix
	ServiceAccountUsernamePrefix = "system:serviceaccount:"
	// ServiceAccountUsernameSeparator is the separator used in service account username.
	ServiceAccountUsernameSeparator = ":"
)

Variables

This section is empty.

Functions

func CreateObjectKey

func CreateObjectKey(partialObjMeta *metav1.PartialObjectMetadata) client.ObjectKey

CreateObjectKey creates a client.ObjectKey from the given PartialObjectMetadata.

func DetermineStatusCode

func DetermineStatusCode(err error) int32

DetermineStatusCode determines the HTTP status code based on the given error.

func GetGroupKindAsStringFromRequest

func GetGroupKindAsStringFromRequest(req admission.Request) string

GetGroupKindAsStringFromRequest returns the GroupKind as a string from the given admission request.

func GetGroupKindFromRequest

func GetGroupKindFromRequest(req admission.Request) schema.GroupKind

GetGroupKindFromRequest returns the GroupKind from the given admission request.

func ServiceAccountMatchesUsername

func ServiceAccountMatchesUsername(namespace, name, username string) bool

ServiceAccountMatchesUsername checks whether the provided username matches the namespace and name Use this when checking a service account namespace and name against a known string.

Types

type RequestDecoder

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

RequestDecoder is a decoder for admission requests.

func NewRequestDecoder

func NewRequestDecoder(mgr manager.Manager) *RequestDecoder

NewRequestDecoder returns a new RequestDecoder.

func (*RequestDecoder) DecodeRequestObjectAsPartialObjectMetadata

func (d *RequestDecoder) DecodeRequestObjectAsPartialObjectMetadata(ctx context.Context, req admission.Request) (*metav1.PartialObjectMetadata, error)

DecodeRequestObjectAsPartialObjectMetadata decodes the request object as a PartialObjectMetadata.

Jump to

Keyboard shortcuts

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