configmaps

package
v0.6.12 Latest Latest
Warning

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

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

Documentation

Overview

Package configmaps provides convenience methods for working with Kubernetes ConfigMaps.

This package provides a Client that wraps the controller-runtime client with ConfigMap-specific operations including Get, GetValue, and Upsert operations.

Example usage:

client := configmaps.NewClient(ctrlClient, scheme)

// Get a ConfigMap
cm, err := client.Get(ctx, "my-configmap", "default")

// Get a specific key's value using ConfigMapKeySelector
value, err := client.GetValue(ctx, "default", configMapKeySelector)

// Upsert a ConfigMap with owner reference
result, err := client.UpsertWithOwnerReference(ctx, configMap, ownerObject)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides convenience methods for working with Kubernetes ConfigMaps.

func NewClient

func NewClient(c client.Client, scheme *runtime.Scheme) *Client

NewClient creates a new configmaps Client instance. The scheme is required for operations that need to set owner references.

func (*Client) Get

func (c *Client) Get(ctx context.Context, name, namespace string) (*corev1.ConfigMap, error)

Get retrieves a Kubernetes ConfigMap by name and namespace. Returns the configmap if found, or an error if not found or on failure.

func (*Client) GetValue

func (c *Client) GetValue(ctx context.Context, namespace string, configMapRef corev1.ConfigMapKeySelector) (string, error)

GetValue retrieves a specific key's value from a Kubernetes ConfigMap. Uses a ConfigMapKeySelector to identify the configmap name and key. Returns the value as a string, or an error if the configmap or key is not found.

func (*Client) Upsert

func (c *Client) Upsert(ctx context.Context, configMap *corev1.ConfigMap) (controllerutil.OperationResult, error)

Upsert creates or updates a Kubernetes ConfigMap without an owner reference. Uses retry logic to handle conflicts from concurrent modifications. Returns the operation result (Created, Updated, or Unchanged) and any error.

func (*Client) UpsertWithOwnerReference

func (c *Client) UpsertWithOwnerReference(
	ctx context.Context,
	configMap *corev1.ConfigMap,
	owner client.Object,
) (controllerutil.OperationResult, error)

UpsertWithOwnerReference creates or updates a Kubernetes ConfigMap with an owner reference. The owner reference ensures the configmap is garbage collected when the owner is deleted. Uses retry logic to handle conflicts from concurrent modifications. Returns the operation result (Created, Updated, or Unchanged) and any error.

Jump to

Keyboard shortcuts

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