Skip to main content

xianyun_core/config/
errors.rs

1//! Port of `internal/config/errors.go`: sentinel errors shared across the
2//! config package.
3
4use thiserror::Error;
5
6#[derive(Debug, Error, PartialEq, Eq)]
7pub enum ConfigError {
8    #[error("configuration file not found: {0}")]
9    ConfigFileNotFound(String),
10    #[error(
11        "no caproni.yaml found in current directory or any parent directory up to home directory"
12    )]
13    NoConfigFileFound,
14    #[error("invalid YAML syntax, must be a YAML mapping: {0}")]
15    InvalidYAML(String),
16
17    #[error("configuration does not match schema: {0}")]
18    SchemaValidation(String),
19    #[error("configuration semantic validation failed: {0}")]
20    SemanticValidation(String),
21    #[error("referenced item not found")]
22    ReferenceNotFound,
23    #[error("referenced file path not found")]
24    PathNotFound,
25    #[error("file variable path references an unresolved variable: {0}")]
26    UnresolvedVariablePath(String),
27    #[error("configuration is missing the required 'version' field")]
28    MissingVersion,
29    #[error("'version' field must be an integer")]
30    InvalidVersion,
31    #[error("deprecated configuration version")]
32    DeprecatedVersion,
33
34    #[error("invalid cluster driver: {0}")]
35    InvalidClusterDriver(String),
36    #[error(
37        "cluster.driver must name a driver directly, variable references are not expanded there: {0:?}"
38    )]
39    DriverNotLiteral(String),
40    #[error(
41        "k3s.disable must name components directly, variable references are not expanded there: {0:?}"
42    )]
43    K3sDisableNotLiteral(String),
44    #[error("invalid memory format: {0}")]
45    InvalidMemoryFormat(String),
46    #[error("invalid namespace format: {0}")]
47    InvalidNamespace(String),
48    #[error("invalid repository type: {0}")]
49    InvalidRepoType(String),
50    #[error("invalid kubernetes type: {0}")]
51    InvalidKubeType(String),
52
53    #[error("tried merging configs with different versions")]
54    OverrideVersionMismatch,
55
56    #[error("extends must be a list of paths")]
57    ExtendsNotList,
58    #[error("extends items must be string paths")]
59    ExtendsItemNotString,
60    #[error("fragment files must not contain extends:")]
61    FragmentHasExtends,
62    #[error("circular extends detected")]
63    CircularExtends,
64    #[error("duplicate fragment in extends: {0}")]
65    DuplicateExtends(String),
66    #[error("fragment path must not escape the config directory")]
67    FragmentOutsideDir,
68    #[error("fragment filename must follow the caproni.<name>.yaml convention")]
69    InvalidFragmentName,
70    #[error("cannot fetch remote fragment: {0}")]
71    RemoteFragmentFetch(String),
72    #[error("cannot resolve a directory reference from a remote fragment")]
73    RemoteFragmentDirRef,
74
75    #[error("caproni-project.yaml 'reloaders' must be a map")]
76    RepoFragmentOnlyReloaders,
77    #[error(
78        "reloaders in caproni-project.yaml must reference the owning repository: reloader {name:?} has repository {repo:?}, expected {expected:?}"
79    )]
80    RepoFragmentWrongRepository {
81        name: String,
82        repo: String,
83        expected: String,
84    },
85    #[error("reloader already defined by another repository fragment: {0:?}")]
86    RepoFragmentDuplicateReloader(String),
87
88    #[error("unsupported config version")]
89    UnsupportedVersion,
90    #[error("config upgrade did not converge to the latest version")]
91    UpgradeLoop,
92    #[error("config is already at the latest version, no migration needed")]
93    AlreadyMigrated,
94    #[error("repository ref is invalid")]
95    InvalidRepositoryRef,
96    #[error("cluster.registry_mirror.endpoint: missing host")]
97    RegistryMirrorEndpointMissingHost,
98    #[error("cluster.registry_mirror.endpoint: missing port (explicit port required)")]
99    RegistryMirrorEndpointMissingPort,
100    #[error(
101        "cluster.registry_mirror.endpoint must not be set when managed is true; caproni computes it"
102    )]
103    RegistryMirrorManagedEndpoint,
104    #[error("repository ref references an unresolved variable")]
105    UnresolvedRepositoryRefVariable,
106}