Expand description
HTTP error code mapping to Kubernetes status condition reasons.
This module provides utilities for mapping HTTP status codes from the Bindcar API to standardized Kubernetes condition reasons. This enables consistent error handling and troubleshooting across the operator.
§Usage
use bindy::http_errors::{map_http_error_to_reason, map_connection_error};
// When making HTTP calls to Bindcar API
match client.get("http://localhost:8080/zones").send().await {
Ok(response) => {
if response.status().is_success() {
// Handle success
} else {
let (reason, message) = map_http_error_to_reason(response.status().as_u16());
// Set condition with this reason
}
}
Err(e) => {
let (reason, message) = map_connection_error();
// Set condition for connection failure
}
}Functions§
- is_
success_ status - Check if HTTP status code indicates success (2xx).
- map_
connection_ error - Map connection error to condition reason and message.
- map_
http_ error_ to_ reason - Map HTTP status code to condition reason and message.
- success_
reason - Get condition reason for successful operations.