Class: LanguageOperator::CLI::Commands::Status
- Inherits:
-
BaseCommand
- Object
- Thor
- BaseCommand
- LanguageOperator::CLI::Commands::Status
- Includes:
- Helpers::UxHelper, LanguageOperator::Constants
- Defined in:
- lib/language_operator/cli/commands/status.rb
Overview
System status and overview command
Constant Summary
Constants included from LanguageOperator::Constants
LanguageOperator::Constants::ALL_MODE_ALIASES, LanguageOperator::Constants::EXECUTION_MODES, LanguageOperator::Constants::PRIMARY_MODES, LanguageOperator::Constants::RESOURCE_AGENT, LanguageOperator::Constants::RESOURCE_AGENT_VERSION, LanguageOperator::Constants::RESOURCE_MODEL, LanguageOperator::Constants::RESOURCE_PERSONA, LanguageOperator::Constants::RESOURCE_TOOL
Instance Method Summary collapse
Methods included from Helpers::UxHelper
#box, #highlight_ruby_code, #logo, #pastel, #prompt, #spinner, #table
Methods included from LanguageOperator::Constants
Instance Method Details
#overview ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/language_operator/cli/commands/status.rb', line 15 def overview handle_command_error('retrieve cluster status') do current_cluster = Config::ClusterConfig.current_cluster clusters = Config::ClusterConfig.list_clusters # Current cluster context if current_cluster cluster_config = Config::ClusterConfig.get_cluster(current_cluster) # Check cluster health k8s = Helpers::ClusterValidator.kubernetes_client(current_cluster) # Try to get actual cluster resource from Kubernetes cluster_resource = nil if k8s.operator_installed? begin cluster_resource = k8s.get_resource('LanguageCluster', current_cluster, cluster_config[:namespace]) rescue StandardError # Cluster resource might not exist yet end end # Early exit if operator not installed unless k8s.operator_installed? logo(title: 'cluster status') puts puts 'Install the operator with:' puts ' langop install' puts return end # Run health checks first logo(title: 'cluster status') begin # Use 'language-operator' namespace for system components, not the cluster namespace health_checker = Helpers::HealthChecker.new(k8s, 'language-operator', current_cluster, cluster_config[:namespace]) health_results = health_checker.run_all_checks # Display any health check failures display_health_summary(health_results) rescue StandardError => e Formatters::ProgressFormatter.error("Health check failed: #{e.}") puts e.backtrace.first(3).join("\n") if ENV['DEBUG'] end # Then show cluster details puts if cluster_resource # Use actual cluster resource data status = cluster_resource.dig('status', 'phase') || 'Unknown' domain = cluster_resource.dig('spec', 'domain') created = cluster_resource.dig('metadata', 'creationTimestamp') org_id = cluster_resource.dig('metadata', 'labels', 'langop.io/organization-id') format_cluster_details( name: current_cluster, namespace: cluster_config[:namespace], context: cluster_config[:context], status: status, domain: domain, created: created, org_id: org_id ) else # Fallback to local config and operator status format_cluster_details( name: current_cluster, namespace: cluster_config[:namespace], context: cluster_config[:context], status: k8s.operator_installed? ? (k8s.operator_version || 'installed') : 'operator not installed' ) end else Formatters::ProgressFormatter.warn('No cluster selected') puts if clusters.any? puts 'Available clusters:' clusters.each do |cluster| puts " - #{cluster[:name]}" end puts puts 'Select a cluster with:' puts ' langop use <cluster>' else puts 'No clusters found. Create one with:' puts ' langop cluster create <name>' end end puts end end |