Skip to main content

cfgd_core/util/
constants.rs

1/// The canonical API version string used in all cfgd YAML documents (local and CRD).
2pub const API_VERSION: &str = "cfgd.io/v1alpha1";
3pub const CSI_DRIVER_NAME: &str = "csi.cfgd.io";
4pub const MODULES_ANNOTATION: &str = "cfgd.io/modules";
5
6/// Kubernetes label key pointing at the `MachineConfig` resource an object
7/// was derived from (e.g. DriftAlert -> MachineConfig).
8pub const LABEL_MACHINE_CONFIG: &str = "cfgd.io/machine-config";
9/// Kubernetes label key identifying the fleet device an object belongs to.
10pub const LABEL_DEVICE_ID: &str = "cfgd.io/device-id";
11/// OCI manifest annotation key carrying the `os/arch` platform string that a
12/// pushed module artifact was built for (parsed by the CSI cache on pull).
13pub const OCI_ANNOTATION_PLATFORM: &str = "cfgd.io/platform";
14
15/// Default timeout for external commands (2 minutes).
16pub const COMMAND_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(120);
17
18/// Default timeout for git network operations (5 minutes).
19pub const GIT_NETWORK_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(300);
20
21/// Default timeout for profile-level scripts (5 minutes).
22pub const PROFILE_SCRIPT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(300);
23
24/// Maximum file size (10 MB) for backup content capture.
25/// Files larger than this are tracked but their content is not stored in backups.
26pub(super) const MAX_BACKUP_FILE_SIZE: u64 = 10 * 1024 * 1024;
27
28/// Named exponential-histogram bucket presets for latency metrics. Kept in
29/// cfgd-core so the SLO-adjacent choice is auditable in one place rather
30/// than divergent inline calls in cfgd-operator and cfgd-csi. Consumers
31/// feed the triple into `prometheus_client::metrics::histogram::exponential_buckets(start, factor, length)`.
32pub const DURATION_BUCKETS_SHORT: (f64, f64, u16) = (0.001, 2.0, 16);
33pub const DURATION_BUCKETS_LONG: (f64, f64, u16) = (0.1, 2.0, 10);