Module selector

Module selector 

Source
Expand description

Label selector matching utilities.

This module provides helper functions for matching Kubernetes label selectors against resource labels. It supports both matchLabels and matchExpressions as defined in the Kubernetes API.

§Architecture

The label selector watch pattern uses kube-rs’s reflector/store to maintain an in-memory cache of resources. When a resource changes, watch mappers synchronously query these caches to find related resources using label selectors.

§Example

use std::collections::BTreeMap;
use bindy::crd::LabelSelector;
use bindy::selector::matches_selector;

let mut labels = BTreeMap::new();
labels.insert("app".to_string(), "web".to_string());

let mut match_labels = BTreeMap::new();
match_labels.insert("app".to_string(), "web".to_string());

let selector = LabelSelector {
    match_labels: Some(match_labels),
    match_expressions: None,
};

assert!(matches_selector(&selector, &labels));

Functions§

matches_selector
Check if a set of labels matches a label selector.