1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! Validation for the deployment-wide index prefix.
//!
//! flusso can prepend a literal prefix to every index name it owns, so several
//! deployments (dev / staging / nightly) can share one OpenSearch cluster
//! without colliding. The prefix is a plain string (the caller includes any
//! separator — `dev_`, `staging-`), resolved at runtime from config, the
//! `FLUSSO_INDEX_PREFIX` env var, or the `--index-prefix` flag.
//!
//! It is prepended verbatim, so the *combined* name must be a legal OpenSearch
//! index name. [`validate_index_prefix`] enforces the part of that contract the
//! prefix controls: lowercase, no characters OpenSearch forbids, and a leading
//! character an index name may legally start with. An empty prefix is the
//! no-op default and always valid.
//!
//! ```
//! use schema_core::validate_index_prefix;
//! assert!(validate_index_prefix("dev_").is_ok());
//! assert!(validate_index_prefix("").is_ok()); // no prefix
//! assert!(validate_index_prefix("Dev_").is_err()); // uppercase
//! assert!(validate_index_prefix("_dev").is_err()); // illegal leading char
//! ```
/// Characters an index name (and therefore a prefix) may never contain — the
/// OpenSearch-forbidden set, plus the comma flusso uses to join indexes in a
/// combined search.
const FORBIDDEN: & = &;
/// Check that `prefix` is a legal leading fragment of an OpenSearch index name.
///
/// An empty prefix is valid (the default — no prefix). A non-empty prefix must
/// be lowercase, contain none of the OpenSearch-forbidden characters, and start
/// with an ASCII letter or digit (an index name may not begin with `_`/`-`/`+`).
/// Returns a human-readable reason on failure, suitable for surfacing at config
/// resolution time.