Fix: Translate all validation messages and UI text from Portuguese to English
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Configurações da aplicação
|
||||
Application settings
|
||||
"""
|
||||
import os
|
||||
from typing import List, Optional
|
||||
@@ -7,17 +7,17 @@ from pydantic_settings import BaseSettings
|
||||
from pydantic import Field
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Configurações da aplicação"""
|
||||
"""Application settings"""
|
||||
|
||||
# Configurações do OpenShift/Kubernetes
|
||||
# OpenShift/Kubernetes settings
|
||||
kubeconfig_path: Optional[str] = None
|
||||
cluster_url: Optional[str] = None
|
||||
token: Optional[str] = None
|
||||
|
||||
# Configurações do Prometheus
|
||||
# Prometheus settings
|
||||
prometheus_url: str = "http://prometheus.openshift-monitoring.svc.cluster.local:9090"
|
||||
|
||||
# Configurações de validação
|
||||
# Validation settings
|
||||
cpu_limit_ratio: float = 3.0 # Ratio padrão limit:request para CPU
|
||||
memory_limit_ratio: float = 3.0 # Ratio padrão limit:request para memória
|
||||
min_cpu_request: str = "10m" # Mínimo de CPU request
|
||||
@@ -32,7 +32,7 @@ class Settings(BaseSettings):
|
||||
"openshift-sdn"
|
||||
]
|
||||
|
||||
# Configurações de filtro de namespaces
|
||||
# Namespace filter settings
|
||||
include_system_namespaces: bool = Field(default=False, alias="INCLUDE_SYSTEM_NAMESPACES")
|
||||
system_namespace_prefixes: List[str] = Field(
|
||||
default=[
|
||||
@@ -50,10 +50,10 @@ class Settings(BaseSettings):
|
||||
env_file = ".env"
|
||||
case_sensitive = False
|
||||
|
||||
# Configurações de relatório
|
||||
# Report settings
|
||||
report_export_path: str = "/tmp/reports"
|
||||
|
||||
# Configurações de segurança
|
||||
# Security settings
|
||||
enable_rbac: bool = True
|
||||
service_account_name: str = "resource-governance-sa"
|
||||
|
||||
|
||||
@@ -38,10 +38,10 @@ class K8sClient:
|
||||
self.apps_v1 = client.AppsV1Api()
|
||||
|
||||
self.initialized = True
|
||||
logger.info("Cliente Kubernetes inicializado com sucesso")
|
||||
logger.info("Kubernetes client initialized successfully")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Erro ao inicializar cliente Kubernetes: {e}")
|
||||
logger.error(f"Error initializing Kubernetes client: {e}")
|
||||
raise
|
||||
|
||||
def _is_system_namespace(self, namespace: str, include_system: bool = None) -> bool:
|
||||
@@ -60,7 +60,7 @@ class K8sClient:
|
||||
async def get_all_pods(self, include_system_namespaces: bool = None) -> List[PodResource]:
|
||||
"""Coletar informações de todos os pods do cluster"""
|
||||
if not self.initialized:
|
||||
raise RuntimeError("Cliente Kubernetes não inicializado")
|
||||
raise RuntimeError("Kubernetes client not initialized")
|
||||
|
||||
pods_data = []
|
||||
|
||||
@@ -110,13 +110,13 @@ class K8sClient:
|
||||
return pods_data
|
||||
|
||||
except ApiException as e:
|
||||
logger.error(f"Erro ao listar pods: {e}")
|
||||
logger.error(f"Error listing pods: {e}")
|
||||
raise
|
||||
|
||||
async def get_namespace_resources(self, namespace: str) -> NamespaceResources:
|
||||
"""Coletar recursos de um namespace específico"""
|
||||
if not self.initialized:
|
||||
raise RuntimeError("Cliente Kubernetes não inicializado")
|
||||
raise RuntimeError("Kubernetes client not initialized")
|
||||
|
||||
# Verificar se é namespace do sistema
|
||||
if self._is_system_namespace(namespace):
|
||||
@@ -179,13 +179,13 @@ class K8sClient:
|
||||
return namespace_resource
|
||||
|
||||
except ApiException as e:
|
||||
logger.error(f"Erro ao coletar recursos do namespace {namespace}: {e}")
|
||||
logger.error(f"Error collecting resources for namespace {namespace}: {e}")
|
||||
raise
|
||||
|
||||
async def get_vpa_recommendations(self) -> List[VPARecommendation]:
|
||||
"""Coletar recomendações do VPA"""
|
||||
if not self.initialized:
|
||||
raise RuntimeError("Cliente Kubernetes não inicializado")
|
||||
raise RuntimeError("Kubernetes client not initialized")
|
||||
|
||||
recommendations = []
|
||||
|
||||
@@ -199,14 +199,14 @@ class K8sClient:
|
||||
return recommendations
|
||||
|
||||
except ApiException as e:
|
||||
logger.error(f"Erro ao coletar recomendações VPA: {e}")
|
||||
logger.error(f"Error collecting VPA recommendations: {e}")
|
||||
# VPA pode não estar instalado, retornar lista vazia
|
||||
return []
|
||||
|
||||
async def get_nodes_info(self) -> List[Dict[str, Any]]:
|
||||
"""Coletar informações dos nós do cluster"""
|
||||
if not self.initialized:
|
||||
raise RuntimeError("Cliente Kubernetes não inicializado")
|
||||
raise RuntimeError("Kubernetes client not initialized")
|
||||
|
||||
try:
|
||||
nodes = self.v1.list_node()
|
||||
@@ -250,5 +250,5 @@ class K8sClient:
|
||||
return nodes_info
|
||||
|
||||
except ApiException as e:
|
||||
logger.error(f"Erro ao coletar informações dos nós: {e}")
|
||||
logger.error(f"Error collecting node information: {e}")
|
||||
raise
|
||||
|
||||
@@ -28,19 +28,19 @@ class PrometheusClient:
|
||||
async with self.session.get(f"{self.base_url}/api/v1/query?query=up") as response:
|
||||
if response.status == 200:
|
||||
self.initialized = True
|
||||
logger.info("Cliente Prometheus inicializado com sucesso")
|
||||
logger.info("Prometheus client initialized successfully")
|
||||
else:
|
||||
logger.warning(f"Prometheus retornou status {response.status}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Erro ao inicializar cliente Prometheus: {e}")
|
||||
logger.error(f"Error initializing Prometheus client: {e}")
|
||||
# Prometheus pode não estar disponível, continuar sem ele
|
||||
self.initialized = False
|
||||
|
||||
async def query(self, query: str, time: Optional[datetime] = None) -> Dict[str, Any]:
|
||||
"""Executar query no Prometheus"""
|
||||
if not self.initialized or not self.session:
|
||||
return {"status": "error", "message": "Prometheus não disponível"}
|
||||
return {"status": "error", "message": "Prometheus not available"}
|
||||
|
||||
try:
|
||||
params = {"query": query}
|
||||
@@ -55,11 +55,11 @@ class PrometheusClient:
|
||||
data = await response.json()
|
||||
return data
|
||||
else:
|
||||
logger.error(f"Erro na query Prometheus: {response.status}")
|
||||
logger.error(f"Error in Prometheus query: {response.status}")
|
||||
return {"status": "error", "message": f"HTTP {response.status}"}
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Erro ao executar query Prometheus: {e}")
|
||||
logger.error(f"Error executing Prometheus query: {e}")
|
||||
return {"status": "error", "message": str(e)}
|
||||
|
||||
async def get_pod_cpu_usage(self, namespace: str, pod_name: str) -> Dict[str, Any]:
|
||||
|
||||
Reference in New Issue
Block a user