object

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package object provides a set of functions to work with the kubernetes objects

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoPostgresContainerFound is raised when there's no PostgreSQL container
	// in the passed instance Pod.
	ErrNoPostgresContainerFound = errors.New("no postgres container into instance Pod")

	// ErrNilPodPassed is raised when a nil Pod is passed to a function requiring it.
	ErrNilPodPassed = errors.New("nil pod passed")
)

Functions

func CreatePatch

func CreatePatch(newObject, oldObject runtime.Object) ([]byte, error)

CreatePatch creates a JSON patch from the diff between the old and new object.

func GetKind

func GetKind(definition []byte) (string, error)

GetKind gets the Kubernetes object kind from its JSON representation.

func InjectPluginInitContainerSidecarSpec added in v0.4.0

func InjectPluginInitContainerSidecarSpec(
	spec *corev1.PodSpec, sidecar *corev1.Container, injectPostgresVolumeMounts bool,
) error

InjectPluginInitContainerSidecarSpec injects a plugin sidecar into a CNPG Pod spec as an InitContainer. This requires the SidecarContainers feature gate to be enabled, which is the default for kubernetes versions >= 1.29.

If the "injectPostgresVolumeMount" flag is true, this will append all the volume mounts that are used in the instance manager Pod to the passed sidecar container, granting it superuser access to the PostgreSQL instance.

Besides the value of "injectPostgresVolumeMount", the plugin volume will always be injected in the PostgreSQL container.

func InjectPluginSidecar deprecated

func InjectPluginSidecar(pod *corev1.Pod, sidecar *corev1.Container, injectPostgresVolumeMounts bool) error

InjectPluginSidecar refer to InjectPluginSidecarSpec.

Deprecated: Kubernetes versions >= 1.29 support sidecars as InitContainers by default, so this function should not be used anymore. Use InjectPluginInitContainerSidecarSpec instead.

func InjectPluginSidecarInitContainer added in v0.4.0

func InjectPluginSidecarInitContainer(pod *corev1.Pod,
	sidecar *corev1.Container,
	injectPostgresVolumeMounts bool,
) error

InjectPluginSidecarInitContainer refer to InjectPluginSidecarInitContainerSpec.

func InjectPluginSidecarSpec deprecated

func InjectPluginSidecarSpec(spec *corev1.PodSpec, sidecar *corev1.Container, injectPostgresVolumeMounts bool) error

InjectPluginSidecarSpec injects a plugin sidecar into a CNPG Pod spec.

If the "injectPostgresVolumeMount" flag is true, this will append all the volume mounts that are used in the instance manager Pod to the passed sidecar container, granting it superuser access to the PostgreSQL instance.

Besides the value of "injectPostgresVolumeMount", the plugin volume will always be injected in the PostgreSQL container.

Deprecated: Kubernetes versions >= 1.29 support sidecars as InitContainers by default, so this function should not be used anymore. Use InjectPluginInitContainerSidecarSpec instead.

func InjectPluginVolume

func InjectPluginVolume(pod *corev1.Pod)

InjectPluginVolume injects the plugin volume into a CNPG Pod.

func InjectPluginVolumeSpec

func InjectPluginVolumeSpec(spec *corev1.PodSpec)

InjectPluginVolumeSpec injects the plugin volume into a CNPG Pod spec.

Types

This section is empty.

Jump to

Keyboard shortcuts

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