zilliz 1.4.1

TUI and CLI tool for managing Zilliz Cloud clusters and Milvus operations
Documentation
use super::manager::ConfigManager;

/// Resolve API key with priority: explicit flag > env var > config file.
pub fn resolve_api_key(explicit: Option<&str>, config_mgr: &ConfigManager) -> Option<String> {
    // 1. Explicit flag (--api-key)
    if let Some(key) = explicit {
        if !key.is_empty() {
            return Some(key.to_string());
        }
    }

    // 2. Environment variable
    if let Ok(key) = std::env::var("ZILLIZ_API_KEY") {
        if !key.is_empty() {
            return Some(key);
        }
    }

    // 3. Config file (~/.zilliz/credentials [default] api_key)
    config_mgr.get_credential("api_key")
}