quickseal 0.1.4

Create Kubernetes SealedSecrets with a single secure command
Documentation
//! Error types for the Seal CLI

use thiserror::Error;

/// Validation errors for user input
#[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),
}

/// Kubernetes configuration errors
#[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),
}

/// Errors during secret sealing process
#[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),
}

/// Main result type for the application
pub type Result<T> = std::result::Result<T, anyhow::Error>;