1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum ValidationError {
8 #[error("Invalid secret name '{name}': {reason}")]
9 InvalidSecretName { name: String, reason: String },
10
11 #[error("Invalid namespace '{namespace}': {reason}")]
12 InvalidNamespace { namespace: String, reason: String },
13
14 #[error("Invalid key name '{key}': {reason}")]
15 InvalidKeyName { key: String, reason: String },
16
17 #[error("Secret data cannot be empty")]
18 EmptySecretData,
19
20 #[error("Too many key-value pairs: {count} (maximum: {max})")]
21 TooManyKeyValuePairs { count: usize, max: usize },
22
23 #[error("Validation error: {0}")]
24 Other(String),
25}
26
27#[derive(Error, Debug)]
29pub enum KubeConfigError {
30 #[error("No kubeconfig found at path: {path}")]
31 NoKubeConfig { path: String },
32
33 #[error("No current context configured: {message}")]
34 NoCurrentContext { message: String },
35
36 #[error("Invalid kubeconfig: {reason}")]
37 InvalidConfig { reason: String },
38
39 #[error("Kubeconfig error: {0}")]
40 Other(String),
41}
42
43#[derive(Error, Debug)]
45pub enum SealingError {
46 #[error("kubeseal binary not found: {message}")]
47 KubesealNotFound { message: String },
48
49 #[error("kubeseal execution failed (exit code {exit_code}): {stderr}")]
50 KubesealExecutionFailed { stderr: String, exit_code: i32 },
51
52 #[error("Output validation failed: {reason}")]
53 OutputValidationFailed { reason: String },
54
55 #[error("Temporary file creation failed: {error}")]
56 TempFileCreationFailed { error: String },
57
58 #[error("Cleanup failed: {error}")]
59 CleanupFailed { error: String },
60
61 #[error("Sealing error: {0}")]
62 Other(String),
63}
64
65pub type Result<T> = std::result::Result<T, anyhow::Error>;