utils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ControllerNameKey = "controller"
	OperandLabelKey   = "multiarch.openshift.io/operand"
	OperatorName      = "multiarch-tuning-operator"
)
View Source
const (
	ArchitectureAmd64   = "amd64"
	ArchitectureArm64   = "arm64"
	ArchitecturePpc64le = "ppc64le"
	ArchitectureS390x   = "s390x"
)
View Source
const (
	ArchLabel                       = "kubernetes.io/arch"
	NodeAffinityLabel               = "multiarch.openshift.io/node-affinity"
	PreferredNodeAffinityLabel      = "multiarch.openshift.io/preferred-node-affinity"
	NodeAffinityLabelValueSet       = "set"
	LabelValueNotSet                = "not-set"
	HostnameLabel                   = "kubernetes.io/hostname"
	SchedulingGateLabel             = "multiarch.openshift.io/scheduling-gate"
	SchedulingGateLabelValueGated   = "gated"
	SchedulingGateLabelValueRemoved = "removed"
	PodPlacementFinalizerName       = "finalizers.multiarch.openshift.io/pod-placement"
	SingleArchLabel                 = "multiarch.openshift.io/single-arch"
	MultiArchLabel                  = "multiarch.openshift.io/multi-arch"
	NoSupportedArchLabel            = "multiarch.openshift.io/no-supported-arch"
	ImageInspectionErrorLabel       = "multiarch.openshift.io/image-inspect-error"
	ImageInspectionErrorCountLabel  = "multiarch.openshift.io/image-inspect-error-count"
	LabelGroup                      = "multiarch.openshift.io"
)
View Source
const (
	// SchedulingGateName is the name of the Scheduling Gate
	SchedulingGateName            = "multiarch.openshift.io/scheduling-gate"
	MasterNodeSelectorLabel       = "node-role.kubernetes.io/master"
	ControlPlaneNodeSelectorLabel = "node-role.kubernetes.io/control-plane"
)
View Source
const (
	PodMutatingWebhookConfigurationName = "pod-placement-mutating-webhook-configuration"
	PodMutatingWebhookName              = "pod-placement-scheduling-gate.multiarch.openshift.io"
	PodPlacementControllerName          = "pod-placement-controller"
	PodPlacementWebhookName             = "pod-placement-web-hook"
)
View Source
const (
	ExecFormatErrorFinalizerName = "finalizers.multiarch.openshift.io/enoexec-events"
	ExecFormatErrorLabelKey      = "multiarch.openshift.io/exec-format-error"
	True                         = "true"
	False                        = "false"
	ExecFormatErrorsDetected     = "ExecFormatErrorsDetected"
	ExecFormatErrorEventReason   = "ExecFormatError"
	UnknownContainer             = "unknown-container" // Used when the container name is not known or not provided
	EnoexecControllerName        = "enoexec-event-handler-controller"
	EnoexecDaemonSet             = "enoexec-event-daemon"
)

Variables

Functions

func AllSupportedArchitecturesSet

func AllSupportedArchitecturesSet() sets.Set[string]

func ApplyResource

func ApplyResource(ctx context.Context, clientSet *kubernetes.Clientset, client *dynamic.DynamicClient, recorder events.Recorder,
	obj client.Object) (client.Object, bool, error)

ApplyResource applies the given object to the cluster. It returns the object as it is in the cluster, a boolean indicating if the object was created or updated and an error if any. TODO[integration-tests]: integration tests for this function in a suite dedicated to this package

func ApplyResources

func ApplyResources(ctx context.Context, clientSet *kubernetes.Clientset, client *dynamic.DynamicClient, recorder events.Recorder,
	objs []client.Object) error

ApplyResources applies the given objects to the cluster. It returns an error if any. TODO[integration-tests]: integration tests for this function in a suite dedicated to this package

func ArchLabelValue

func ArchLabelValue(arch string) string

func Buckets

func Buckets() []float64

func DeleteResource

func DeleteResource(ctx context.Context, namespacedTypedClient DeleterInterface, objName string) error

DeleteResource deletes the given object from the cluster. It returns an error if any. TODO[integration-tests]: integration tests for this function in a suite dedicated to this package

func DeleteResources

func DeleteResources(ctx context.Context, toDeleteRefs []ToDeleteRef) error

DeleteResources deletes the given objects from the cluster. It returns an error if any. TODO[integration-tests]: integration tests for this function in a suite dedicated to this package

func ExecFormatErrorEventMessage added in v1.2.0

func ExecFormatErrorEventMessage(containerName, nodeArch string) string

func ExtractAuthFromSecret

func ExtractAuthFromSecret(secret *v1.Secret) ([]byte, error)

func HistogramObserve

func HistogramObserve(initialTime time.Time, histogram prometheus.Histogram)

func Image

func Image() string

Image returns the image used to run the operator.

func IsResourceAvailable

func IsResourceAvailable(ctx context.Context, client *dynamic.DynamicClient, resource schema.GroupVersionResource) bool

func Namespace

func Namespace() string

Namespace returns the namespace where the operator's pods are running.

func NewPtr

func NewPtr[T any](a T) *T

func ShouldStdErr added in v1.2.0

func ShouldStdErr(fn func() error)

func ToZapLevel added in v1.2.2

func ToZapLevel(level int) (zapcore.Level, error)

ToZapLevel converts an int log level to zapcore.Level with overflow validation. The input is negated before conversion (positive values become negative for zap). Returns an error if the value would overflow int8 range (-128 to 127).

Types

type DeleterInterface

type DeleterInterface interface {
	Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error
}

DeleterInterface abstracts the Delete method of a typed and namespaced client got from a clientset

func NewDynamicDeleter

func NewDynamicDeleter(dynamicClient dynamic.ResourceInterface) DeleterInterface

type ToDeleteRef

type ToDeleteRef struct {
	NamespacedTypedClient DeleterInterface
	ObjName               string
}

Jump to

Keyboard shortcuts

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