use thiserror::Error;
#[derive(Error, Debug)]
pub enum ValidationError {
#[error("Invalid secret name '{name}': {reason}")]
InvalidSecretName { name: String, reason: String },
#[error("Invalid namespace '{namespace}': {reason}")]
InvalidNamespace { namespace: String, reason: String },
#[error("Invalid key name '{key}': {reason}")]
InvalidKeyName { key: String, reason: String },
#[error("Secret data cannot be empty")]
EmptySecretData,
#[error("Too many key-value pairs: {count} (maximum: {max})")]
TooManyKeyValuePairs { count: usize, max: usize },
#[error("Validation error: {0}")]
Other(String),
}
#[derive(Error, Debug)]
pub enum KubeConfigError {
#[error("No kubeconfig found at path: {path}")]
NoKubeConfig { path: String },
#[error("No current context configured: {message}")]
NoCurrentContext { message: String },
#[error("Invalid kubeconfig: {reason}")]
InvalidConfig { reason: String },
#[error("Kubeconfig error: {0}")]
Other(String),
}
#[derive(Error, Debug)]
pub enum SealingError {
#[error("kubeseal binary not found: {message}")]
KubesealNotFound { message: String },
#[error("kubeseal execution failed (exit code {exit_code}): {stderr}")]
KubesealExecutionFailed { stderr: String, exit_code: i32 },
#[error("Output validation failed: {reason}")]
OutputValidationFailed { reason: String },
#[error("Temporary file creation failed: {error}")]
TempFileCreationFailed { error: String },
#[error("Cleanup failed: {error}")]
CleanupFailed { error: String },
#[error("Sealing error: {0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, anyhow::Error>;