common

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

pkg/resources/common/probes.go

pkg/resources/common/resource.go

pkg/resources/common/rolling_update.go

pkg/resources/common/security.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyProbes

func ApplyProbes(c *corev1.Container, probes *orktypes.ProbesConfig, containerPort int32)

ApplyProbes sets startup, liveness, and readiness probes on c. containerPort is used for probes that do not declare their own port. No-op when probes is nil.

func ApplySecurityContext

func ApplySecurityContext(container *corev1.Container, pod *corev1.PodSpec, sc *orktypes.ContainerSecurityContext, ps *orktypes.PodSecurityContext)

ApplySecurityContext sets the container security context and pod security context on the given container and pod spec. No-op when both are nil.

func BuildContainerSecurityContext

func BuildContainerSecurityContext(sc *orktypes.ContainerSecurityContext) *corev1.SecurityContext

BuildContainerSecurityContext converts an orktypes.ContainerSecurityContext to a Kubernetes corev1.SecurityContext. Returns nil when sc is nil.

func BuildDeploymentRollingUpdateStrategy

func BuildDeploymentRollingUpdateStrategy(r *orktypes.RollingUpdateBehavior) appsv1.DeploymentStrategy

BuildDeploymentRollingUpdateStrategy converts a RollingUpdateBehavior into an appsv1.DeploymentStrategy. Both MaxSurge and MaxUnavailable are applied.

func BuildPodSecurityContext

func BuildPodSecurityContext(ps *orktypes.PodSecurityContext) *corev1.PodSecurityContext

BuildPodSecurityContext converts an orktypes.PodSecurityContext to a Kubernetes corev1.PodSecurityContext. Returns nil when ps is nil.

func BuildProbe

func BuildProbe(cfg *orktypes.ProbeConfig, containerPort int32) *corev1.Probe

BuildProbe constructs a Kubernetes Probe from a ProbeConfig. containerPort is used as the probe target when cfg.Port is 0. Returns nil if cfg is nil or no probe type can be inferred.

func BuildResourceRequirements

func BuildResourceRequirements(r *orktypes.ResourceRequirements) corev1.ResourceRequirements

BuildResourceRequirements converts an Orkestra ResourceRequirements spec into a Kubernetes corev1.ResourceRequirements object.

func BuildStatefulSetUpdateStrategy

func BuildStatefulSetUpdateStrategy(r *orktypes.RollingUpdateBehavior) appsv1.StatefulSetUpdateStrategy

BuildStatefulSetUpdateStrategy converts a RollingUpdateBehavior into an appsv1.StatefulSetUpdateStrategy. Only MaxUnavailable applies — StatefulSets do not support MaxSurge.

func BuildVolumeMounts

func BuildVolumeMounts(mounts []orktypes.VolumeMount) []corev1.VolumeMount

BuildVolumeMounts converts a slice of VolumeMount declarations into Kubernetes corev1.VolumeMount objects ready to set on a Container. Returns nil when the input is empty.

func BuildVolumes

func BuildVolumes(vols []orktypes.VolumeSource) []corev1.Volume

BuildVolumes converts a slice of VolumeSource declarations into Kubernetes corev1.Volume objects ready to set on PodSpec.Volumes. Returns nil when the input is empty.

func LabelsEqual

func LabelsEqual(a, b map[string]string) bool

LabelsEqual reports whether two maps of labels are equivalent.

func ParseBool

func ParseBool(s string) bool

ParseBool interprets common boolean representations from template expressions.

func ParseIntOrPercent

func ParseIntOrPercent(s string) intstr.IntOrString

ParseIntOrPercent converts a string to intstr.IntOrString. Strings ending in "%" are treated as percentage strings; others as integers.

func ParsePort

func ParsePort(s string) int

ParsePort interprets common port representations from template expressions.

func ParseProtocol

func ParseProtocol(s string) corev1.Protocol

ParseProtocol converts a protocol string to a corev1.Protocol. Accepted values: TCP (default), UDP, SCTP — case-insensitive. Empty string and anything unrecognised defaults to TCP, matching Kubernetes behaviour.

func ParseReplicas

func ParseReplicas(s string) int32

ParseReplicas parses a replica count string, defaulting to 1 when empty or unparseable.

func ResolveContainerSecurityContext

func ResolveContainerSecurityContext(sc *orktypes.ContainerSecurityContext) *orktypes.ContainerSecurityContext

ResolveContainerSecurityContext resolves a ContainerSecurityContext: if a profile is set it expands to explicit fields; otherwise the block is returned as-is. Returns nil when sc is nil.

func ResolveNamespace

func ResolveNamespace(owner domain.Object, namespace string) string

ResolveNamespace — priority: spec.Namespace → owner namespace → "default"

func ResolvePodSecurityContext

func ResolvePodSecurityContext(ps *orktypes.PodSecurityContext) *orktypes.PodSecurityContext

ResolvePodSecurityContext resolves a PodSecurityContext: if a profile is set it expands to explicit fields; otherwise the block is returned as-is. Returns nil when ps is nil.

func ResolveResources

ResolveResources resolves resource requirements: if resources.profile is set it expands to explicit requests/limits; otherwise the block is returned as-is. Returns nil when neither profile nor explicit values are declared.

func ResourceRequirementsEqual

func ResourceRequirementsEqual(a, b corev1.ResourceRequirements) bool

ResourceRequirementsEqual reports whether two ResourceRequirements are equivalent.

func SleepIfNeeded

func SleepIfNeeded(s string) error

SleepIfNeeded parses an extended duration string and sleeps if non-zero. Used by all operatorBox resources to inject artificial latency for autoscaling tests, chaos engineering, and latency simulation.

func SyncContainerSpec

func SyncContainerSpec(existing *corev1.Container, desired corev1.Container) bool

SyncContainerSpec applies template-declared fields from desired to existing and returns true if anything changed.

Guard: a field is only synced when desired is non-zero/non-nil. A zero value means the Orkestra template did not declare the field — Kubernetes may have defaulted it, and we must not overwrite its defaults with empty values on every reconcile. This is the standard "declared intent" principle: only correct drift for fields the operator owns.

func SyncPodSpec

func SyncPodSpec(existing *corev1.PodSpec, desired corev1.PodSpec) bool

SyncPodSpec applies template-declared pod-level fields from desired to existing. Returns true if anything changed. Same guard principle as SyncContainerSpec — zero/nil in desired means the template did not declare the field.

func ToPullSecrets

func ToPullSecrets(names []string) []corev1.LocalObjectReference

ToPullSecrets converts a slice of string to a []corev1.LocalObjectReference Acceptable as Pull secrets

Types

This section is empty.

Jump to

Keyboard shortcuts

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