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 ¶
- type Client
- func (c *Client) Get(ctx context.Context, name, namespace string) (*corev1.ConfigMap, error)
- func (c *Client) GetValue(ctx context.Context, namespace string, ...) (string, error)
- func (c *Client) Upsert(ctx context.Context, configMap *corev1.ConfigMap) (controllerutil.OperationResult, error)
- func (c *Client) UpsertWithOwnerReference(ctx context.Context, configMap *corev1.ConfigMap, owner client.Object) (controllerutil.OperationResult, error)
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 ¶
NewClient creates a new configmaps Client instance. The scheme is required for operations that need to set owner references.
func (*Client) Get ¶
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. Returns the operation result (Created, Updated, or Unchanged) and any error. Callers should return errors to let the controller work queue handle retries.
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. Returns the operation result (Created, Updated, or Unchanged) and any error. Callers should return errors to let the controller work queue handle retries.