Class: Captive::Commands::AppsCommands
- Inherits:
-
Thor
- Object
- Thor
- Captive::Commands::AppsCommands
- Includes:
- Captive::CLIDependencies
- Defined in:
- lib/captive/commands/apps_commands.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
8 |
# File 'lib/captive/commands/apps_commands.rb', line 8 def self.exit_on_failure? = true |
Instance Method Details
#info(app) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/captive/commands/apps_commands.rb', line 42 def info(app) i = AppsInfo.new(kubectl: kubectl).gather(app) puts paint.bold("\n#{app}") puts " Stage : #{i[:stage] || "–"}" puts " Tier : #{i[:tier] || "–"}" puts " Pod : #{i[:pod_status]} (#{i[:replicas]} replica(s))" puts " Postgres : #{i[:postgres] ? paint.green("✓") : paint.dim("–")}" puts " Redis : #{i[:redis] ? paint.green("✓") : paint.dim("–")}" puts " IP fixe : #{i[:egress_ip] ? paint.green("✓") : paint.dim("–")}" i[:domains]&.any? && i[:domains].each { |d| puts " → #{d}" } i[:workers]&.any? && puts(" Workers : #{i[:workers].join(", ")}") (pg = i[:postgres_details]) && puts(" Postgres : #{pg[:instances] || 1} instance(s), #{pg[:memory] || "–"} RAM") (rd = i[:redis_details]) && puts(" Redis : #{rd[:memory] || "–"} RAM, #{rd[:storage] || "–"}") (eg = i[:egress_ip_details]) && puts(" IP fixe : #{eg[:ip] || "–"}") puts end |
#list ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/captive/commands/apps_commands.rb', line 17 def list apps = ClusterApps.new(kubectl: kubectl).all puts paint.bold("Apps (#{apps.size}) :") apps.each do |app| stage_badge = case app[:stage] when "staging" then " " + paint.yellow("[staging]") when "production" then " " + paint.green("[prod]") else "" end puts " - #{paint.bold(app[:name])}#{stage_badge}" if app[:domains]&.any? app[:domains].each { |d| puts " #{paint.cyan("https://#{d}")}" } else puts paint.dim(" <no domain>") end end end |
#rebuild(app) ⇒ Object
85 86 87 88 89 90 |
# File 'lib/captive/commands/apps_commands.rb', line 85 def rebuild(app) AppsRebuild.new(gh: gh_cli).run(app) puts paint.green(" ✓ Rebuild déclenché pour '#{app}'") rescue WorkflowDispatchNotConfigured, ImageYamlNotFound, PlatformRootNotFound => e abort paint.red("✗ #{e.}") end |
#restart(app) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/captive/commands/apps_commands.rb', line 66 def restart(app) AppsRestart.new(kubectl: kubectl).run(app) pod_name, created_at = kubectl.pod_info(app, app) age = format_age(created_at) puts paint.green(" ✓ #{app} redémarré") puts paint.dim(" pod: #{pod_name} (#{age})") rescue PollTimeout => e abort paint.red("✗ Timeout : #{e.}") rescue RuntimeError => e abort paint.red("✗ #{e..split("failed: ").last}") end |