@vfarcic/dot-ai
Version:
Universal Kubernetes application deployment agent with CLI and MCP interfaces
28 lines (27 loc) • 1.41 kB
JavaScript
;
/**
* Cluster Connection Utilities
*
* Provides reusable functions for lazy cluster connectivity checking
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.ensureClusterConnection = ensureClusterConnection;
const error_handling_1 = require("./error-handling");
/**
* Ensures cluster connectivity and throws proper MCP-compatible errors
*/
async function ensureClusterConnection(dotAI, logger, requestId, component) {
logger.debug('Checking cluster connectivity', { requestId, component });
try {
await dotAI.discovery.connect();
logger.debug('Cluster connectivity verified', { requestId, component });
}
catch (clusterError) {
const errorMessage = clusterError instanceof Error ? clusterError.message : String(clusterError);
throw error_handling_1.ErrorHandler.createError(error_handling_1.ErrorCategory.KUBERNETES, error_handling_1.ErrorSeverity.HIGH, `Cluster connection failed: ${errorMessage}\n\nTroubleshooting:\n- Check KUBECONFIG environment variable\n- Verify cluster is running: kubectl cluster-info\n- Test kubectl connectivity: kubectl get nodes\n- Ensure cluster is accessible from this environment`, {
operation: 'cluster_connectivity_check',
component,
requestId
}, clusterError instanceof Error ? clusterError : new Error(String(clusterError)));
}
}