Class: Odysseus::CLI::CLI
- Inherits:
-
Object
- Object
- Odysseus::CLI::CLI
- Includes:
- DoctorCommands, InteractiveCommands, RollbackCommands, SetupCommands
- Defined in:
- lib/odysseus/cli/cli.rb
Constant Summary
Constants included from SetupCommands
SetupCommands::DEFAULT_IDENTITY
Instance Method Summary collapse
-
#app_exec(server, options = {}) ⇒ Object
App exec.
-
#build(options = {}) ⇒ Object
Build command.
-
#cleanup(server, options = {}) ⇒ Object
Cleanup command.
-
#containers(server, options = {}) ⇒ Object
Containers command.
-
#dependency_boot(options = {}) ⇒ Object
Dependency commands.
- #dependency_boot_all(options = {}) ⇒ Object
-
#dependency_exec(server, options = {}) ⇒ Object
Dependency exec.
-
#dependency_logs(server, options = {}) ⇒ Object
Dependency logs.
- #dependency_remove(options = {}) ⇒ Object
- #dependency_restart(options = {}) ⇒ Object
- #dependency_status(options = {}) ⇒ Object
- #dependency_upgrade(options = {}) ⇒ Object
-
#deploy(options = {}) ⇒ Object
Deploy command.
-
#initialize(debug: false) ⇒ CLI
constructor
A new instance of CLI.
-
#logs(server, options = {}) ⇒ Object
Logs command.
-
#pussh(options = {}) ⇒ Object
Pussh command.
- #secrets_decrypt(options = {}) ⇒ Object
- #secrets_edit(options = {}) ⇒ Object
- #secrets_encrypt(options = {}) ⇒ Object
-
#secrets_generate_key(_options = {}) ⇒ Object
Secrets commands.
-
#status(server, options = {}) ⇒ Object
Status command.
-
#validate(options = {}) ⇒ Object
Validate command.
Methods included from SetupCommands
Methods included from DoctorCommands
Methods included from InteractiveCommands
#app_console, #app_shell, #dependency_shell
Methods included from RollbackCommands
Constructor Details
Instance Method Details
#app_exec(server, options = {}) ⇒ Object
App exec
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/odysseus/cli/cli.rb', line 482 def app_exec(server, = {}) config_file = [:config] || 'deploy.yml' role = ([:role] || 'web').to_sym command = [:command] unless command @ui.error 'Command required (--command)' exit 1 end config = load_config(config_file) image = running_image(server, config, role) @ui.header 'App Exec' @ui.info 'Server', server @ui.info 'Role', role @ui.info 'Command', command @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) env = build_environment(config, config_file, ssh) puts docker.run_once(image: image, command: command, options: { env: env, network: 'odysseus' }) ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#build(options = {}) ⇒ Object
Build command
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 |
# File 'lib/odysseus/cli/cli.rb', line 77 def build( = {}) config_file = [:config] || 'deploy.yml' image_tag = [:image] push = [:push] || false context_path = [:context] verbose = [:verbose] || @ui.debug? config = load_config(config_file) executor = Odysseus::Deployer::Executor.new(config_file, verbose: verbose) resolved = executor.deploy_version(image_tag) @ui.header 'Odysseus Build' @ui.info 'Image', "#{config[:image]}:#{resolved.version}" @ui.info 'Strategy', (config.dig(:builder, :strategy) || :local).to_s @ui.blank result = @ui.spin_step("Building image #{config[:image]}:#{resolved.version}") do executor.build(image_tag: image_tag, push: push, context_path: context_path) end if result[:success] @ui.step_ok 'Pushed to registry' if result[:pushed] @ui.step_ok 'Build complete' else @ui.step_fail "Build failed: #{result[:error]}" exit 1 end rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#cleanup(server, options = {}) ⇒ Object
Cleanup command
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 |
# File 'lib/odysseus/cli/cli.rb', line 556 def cleanup(server, = {}) config_file = [:config] || 'deploy.yml' prune_images = [:all] || false config = load_config(config_file) service_name = config[:service] @ui.header 'Odysseus Cleanup' @ui.info 'Service', service_name @ui.info 'Server', server @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) caddy = Odysseus::Caddy::Client.new(ssh: ssh, docker: docker) if @ui.debug? @ui.section 'Disk usage (before)' puts docker.disk_usage @ui.blank end service_names = [service_name] config[:servers].keys.reject { |r| r == :web }.each { |role| service_names << "#{service_name}-#{role}" } config[:dependencies]&.each_key { |name| service_names << "#{service_name}-#{name}" } total_removed = 0 service_names.each do |svc| containers = docker.list(service: svc, all: true) containers.each do |c| docker.stop(c['ID'], timeout: 10) if c['State'] == 'running' docker.remove(c['ID'], force: true) total_removed += 1 end end @ui.step "Removed #{total_removed} container(s)" # Clean Caddy routes if caddy.running? begin caddy.remove_upstream(service: service_name, upstream: nil) rescue StandardError nil end config[:dependencies]&.each do |name, acc_config| next unless acc_config[:proxy] begin caddy.remove_upstream(service: "#{service_name}-#{name}", upstream: nil) rescue StandardError nil end end remaining = caddy.list_services.reject { |s| s[:service] == 'unknown' || s[:service].empty? } if remaining.empty? begin docker.stop('odysseus-caddy', timeout: 10) rescue StandardError nil end begin docker.remove('odysseus-caddy', force: true) rescue StandardError nil end @ui.step 'Caddy removed (no other services)' else @ui.step "Caddy kept (#{remaining.size} other service(s))" end end if prune_images @ui.step 'Pruning dangling images...' docker.prune(containers: false, images: true, volumes: false, networks: false) end @ui.blank @ui.success 'Cleanup complete' ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#containers(server, options = {}) ⇒ Object
Containers command
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/odysseus/cli/cli.rb', line 256 def containers(server, = {}) config_file = [:config] || 'deploy.yml' @ui.header 'Odysseus Containers' @ui.info 'Server', server @ui.blank config = load_config(config_file) service_name = [:service] || config[:service] ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) containers = docker.list(service: service_name) if containers.empty? @ui.step "No containers found for #{service_name}" else rows = containers.map do |c| [c['ID'][0..11], c['State'], c['Names'], c['Image'], c['Status']] end @ui.table(headers: %w[ID State Name Image Status], rows: rows) end ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#dependency_boot(options = {}) ⇒ Object
Dependency commands
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'lib/odysseus/cli/cli.rb', line 306 def dependency_boot( = {}) config_file = [:config] || 'deploy.yml' name = require_name!() @ui.header 'Dependency Boot' @ui.info 'Dependency', name @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) @ui.spin_step("Booting #{name}...") { executor.deploy_dependency(name: name) } @ui.step_ok "Dependency #{name} deployed" rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#dependency_boot_all(options = {}) ⇒ Object
322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/odysseus/cli/cli.rb', line 322 def dependency_boot_all( = {}) config_file = [:config] || 'deploy.yml' @ui.header 'Dependency Boot All' @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) @ui.spin_step('Booting all dependencies...') { executor.boot_dependencies } @ui.step_ok 'All dependencies deployed' rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#dependency_exec(server, options = {}) ⇒ Object
Dependency exec
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/odysseus/cli/cli.rb', line 517 def dependency_exec(server, = {}) config_file = [:config] || 'deploy.yml' name = require_name!() command = [:command] unless command @ui.error 'Command required (--command)' exit 1 end config = load_config(config_file) service_name = "#{config[:service]}-#{name}" @ui.header 'Dependency Exec' @ui.info 'Dependency', name @ui.info 'Command', command @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) containers = docker.list(service: service_name) if containers.empty? @ui.error "No running containers found for #{service_name}" exit 1 end puts docker.exec(containers.first['ID'], command) ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#dependency_logs(server, options = {}) ⇒ Object
Dependency logs
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/odysseus/cli/cli.rb', line 446 def dependency_logs(server, = {}) config_file = [:config] || 'deploy.yml' name = require_name!() follow = [:follow] || false lines = [:lines] || 100 since = [:since] config = load_config(config_file) service_name = "#{config[:service]}-#{name}" @ui.header "Dependency Logs: #{service_name}" @ui.info 'Server', server @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) container_id = log_container_id!(docker, service_name, server, config) if follow @ui.step 'Following logs (Ctrl+C to stop)...' @ui.blank docker.logs(container_id, follow: true, tail: lines, since: since) { |line| print line } else puts docker.logs(container_id, tail: lines, since: since) end ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#dependency_remove(options = {}) ⇒ Object
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
# File 'lib/odysseus/cli/cli.rb', line 336 def dependency_remove( = {}) config_file = [:config] || 'deploy.yml' name = require_name!() @ui.header 'Dependency Remove' @ui.info 'Dependency', name @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) @ui.spin_step("Removing #{name}...") { executor.remove_dependency(name: name) } @ui.step_ok "Dependency #{name} removed" rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#dependency_restart(options = {}) ⇒ Object
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'lib/odysseus/cli/cli.rb', line 352 def dependency_restart( = {}) config_file = [:config] || 'deploy.yml' name = require_name!() @ui.header 'Dependency Restart' @ui.info 'Dependency', name @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) @ui.spin_step("Restarting #{name}...") { executor.restart_dependency(name: name) } @ui.step_ok "Dependency #{name} restarted" rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#dependency_status(options = {}) ⇒ Object
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/odysseus/cli/cli.rb', line 384 def dependency_status( = {}) config_file = [:config] || 'deploy.yml' @ui.header 'Dependency Status' @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) statuses = executor.dependency_status if statuses.empty? @ui.step 'No dependencies configured' else rows = statuses.map do |s| state = s[:running] ? 'running' : 'stopped' container = s[:container_id] ? s[:container_id][0..11] : '-' proxy = s[:has_proxy] ? '✓' : '' [s[:name].to_s, s[:host], state, s[:image], container, proxy] end @ui.table(headers: %w[Name Host State Image Container Proxy], rows: rows) end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#dependency_upgrade(options = {}) ⇒ Object
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/odysseus/cli/cli.rb', line 368 def dependency_upgrade( = {}) config_file = [:config] || 'deploy.yml' name = require_name!() @ui.header 'Dependency Upgrade' @ui.info 'Dependency', name @ui.blank executor = Odysseus::Deployer::Executor.new(config_file) @ui.spin_step("Upgrading #{name}...") { executor.upgrade_dependency(name: name) } @ui.step_ok "Dependency #{name} upgraded" rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#deploy(options = {}) ⇒ Object
Deploy command
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 |
# File 'lib/odysseus/cli/cli.rb', line 25 def deploy( = {}) config_file = [:config] || 'deploy.yml' image_tag = [:image] should_build = [:build] || false dry_run = [:'dry-run'] || false verbose = [:verbose] || @ui.debug? config = load_config(config_file) uses_registry = config[:registry] && config[:registry][:server] executor = Odysseus::Deployer::Executor.new(config_file, verbose: verbose) resolved = executor.deploy_version(image_tag) distribution = uses_registry ? "registry (#{config[:registry][:server]})" : 'pussh (SSH)' @ui.deploy_header( service: config[:service], image: config[:image], image_tag: resolved.version, build: should_build, distribution: distribution ) start_time = Time.now if should_build # Build phase — captured as streaming steps @ui.stream_steps(title: 'Building and distributing') do build_result = executor.build_and_distribute(image_tag: image_tag) raise Odysseus::BuildError, "Build failed: #{build_result[:build][:error]}" unless build_result[:build][:success] if uses_registry raise Odysseus::BuildError, 'Push to registry failed' unless build_result[:push][:success] else raise Odysseus::BuildError, 'Image distribution failed' unless build_result[:pussh][:success] end end end # Deploy phase — each orchestrator log line becomes a sub-step @ui.stream_steps(title: 'Deploying service') do executor.deploy_all(image_tag: image_tag, dry_run: dry_run) end duration = (Time.now - start_time).round(1) @ui.deploy_complete(duration: duration) rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#logs(server, options = {}) ⇒ Object
Logs command
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
# File 'lib/odysseus/cli/cli.rb', line 410 def logs(server, = {}) config_file = [:config] || 'deploy.yml' role = ([:role] || 'web').to_sym follow = [:follow] || false lines = [:lines] || 100 since = [:since] config = load_config(config_file) service_name = Odysseus::Docker::Labels.service_for(service: config[:service], role: role) @ui.header "Logs: #{service_name}" @ui.info 'Server', server @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) container_id = log_container_id!(docker, service_name, server, config, role: role) if follow @ui.step 'Following logs (Ctrl+C to stop)...' @ui.blank docker.logs(container_id, follow: true, tail: lines, since: since) { |line| print line } else puts docker.logs(container_id, tail: lines, since: since) end ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#pussh(options = {}) ⇒ Object
Pussh command
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/odysseus/cli/cli.rb', line 111 def pussh( = {}) config_file = [:config] || 'deploy.yml' image_tag = [:image] should_build = [:build] || false verbose = [:verbose] || @ui.debug? config = load_config(config_file) executor = Odysseus::Deployer::Executor.new(config_file, verbose: verbose) resolved = executor.deploy_version(image_tag) @ui.header 'Odysseus Pussh' @ui.info 'Image', "#{config[:image]}:#{resolved.version}" @ui.blank if should_build result = @ui.spin_step("Building image #{config[:image]}:#{resolved.version}") do executor.build_and_pussh(image_tag: image_tag) end unless result[:build][:success] @ui.step_fail "Build failed: #{result[:build][:error]}" exit 1 end pussh_result = result[:pussh] else pussh_result = @ui.spin_step('Pushing image via SSH...') do executor.pussh(image_tag: image_tag) end end if pussh_result[:success] @ui.step_ok "Pussh complete (#{pussh_result[:results]&.size || 0} host(s))" else @ui.step_fail 'Pussh failed' exit 1 end rescue Odysseus::Error => e @ui.step_fail e. exit 1 end |
#secrets_decrypt(options = {}) ⇒ Object
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 |
# File 'lib/odysseus/cli/cli.rb', line 693 def secrets_decrypt( = {}) secrets_file = [:file] || 'secrets.yml.enc' unless File.exist?(secrets_file) @ui.error "Secrets file not found: #{secrets_file}" exit 1 end @ui.header 'Secrets: Decrypt' @ui.info 'File', secrets_file @ui.blank encrypted_file = Odysseus::Secrets::EncryptedFile.new(secrets_file) secrets = encrypted_file.read secrets.each do |key, value| masked = value.to_s.length > 4 ? "#{value[0..3]}#{'*' * (value.length - 4)}" : '****' @ui.info key, masked end @ui.blank @ui.step '(values masked)' rescue Odysseus::Secrets::EncryptedFile::MissingKeyError, Odysseus::Secrets::EncryptedFile::DecryptionError => e @ui.error e. exit 1 end |
#secrets_edit(options = {}) ⇒ Object
719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
# File 'lib/odysseus/cli/cli.rb', line 719 def secrets_edit( = {}) secrets_file = [:file] || 'secrets.yml.enc' editor = ENV['EDITOR'] || 'vi' @ui.header 'Secrets: Edit' @ui.info 'File', secrets_file @ui.info 'Editor', editor @ui.blank encrypted_file = Odysseus::Secrets::EncryptedFile.new(secrets_file) secrets = encrypted_file.exists? ? encrypted_file.read : {} temp_file = Tempfile.new(['secrets', '.yml']) begin temp_file.write(YAML.dump(secrets)) temp_file.close system("#{editor} #{temp_file.path}") edited_secrets = YAML.load_file(temp_file.path) encrypted_file.write(edited_secrets) @ui.success 'Secrets updated and encrypted' ensure temp_file.unlink end rescue Odysseus::Secrets::EncryptedFile::MissingKeyError => e @ui.error e. @ui.step 'Generate a key with: odysseus secrets generate-key' exit 1 rescue Odysseus::Error => e @ui.error e. exit 1 end |
#secrets_encrypt(options = {}) ⇒ Object
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
# File 'lib/odysseus/cli/cli.rb', line 660 def secrets_encrypt( = {}) input_file = [:input] output_file = [:file] || 'secrets.yml.enc' unless input_file @ui.error 'Input file required (--input)' exit 1 end unless File.exist?(input_file) @ui.error "Input file not found: #{input_file}" exit 1 end @ui.header 'Secrets: Encrypt' @ui.info 'Input', input_file @ui.info 'Output', output_file @ui.blank secrets = YAML.load_file(input_file) encrypted_file = Odysseus::Secrets::EncryptedFile.new(output_file) encrypted_file.write(secrets) @ui.success "Secrets encrypted to #{output_file}" rescue Odysseus::Secrets::EncryptedFile::MissingKeyError => e @ui.error e. @ui.step 'Generate a key with: odysseus secrets generate-key' exit 1 rescue Odysseus::Error => e @ui.error e. exit 1 end |
#secrets_generate_key(_options = {}) ⇒ Object
Secrets commands
647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/odysseus/cli/cli.rb', line 647 def secrets_generate_key( = {}) @ui.header 'Secrets: Generate Key' @ui.blank key = Odysseus::Secrets::EncryptedFile.generate_key @ui.success 'Generated master key:' @ui.blank puts " #{key}" @ui.blank @ui.warn 'Save this key securely!' @ui.step 'Set as ODYSSEUS_MASTER_KEY environment variable' end |
#status(server, options = {}) ⇒ Object
Status command
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/odysseus/cli/cli.rb', line 154 def status(server, = {}) config_file = [:config] || 'deploy.yml' config = load_config(config_file) service_name = config[:service] @ui.header 'Odysseus Status' @ui.info 'Service', service_name @ui.info 'Server', server @ui.blank ssh = connect_to_server(server, config) begin docker = Odysseus::Docker::Client.new(ssh) caddy = Odysseus::Caddy::Client.new(ssh: ssh, docker: docker) # Web containers @ui.section 'Web' web_containers = docker.list(service: service_name) if web_containers.empty? @ui.step '(no containers running)' else rows = web_containers.map { |c| web_container_row(c) } @ui.table(headers: %w[Version Ref Deployed Image State Health], rows: rows) end caddy_status = caddy.status if caddy_status[:running] svc_route = caddy_status[:services].find { |s| s[:service] == service_name } if svc_route @ui.info 'Proxy', svc_route[:hosts].join(', ') @ui.info 'Upstreams', svc_route[:upstreams].join(', ') end end @ui.blank # Workers non_web_roles = config[:servers].keys.reject { |r| r == :web } if non_web_roles.any? @ui.section 'Workers' rows = [] non_web_roles.each do |role| role_service = "#{service_name}-#{role}" containers = docker.list(service: role_service) if containers.empty? rows << [role.to_s, 'stopped', '-', '-'] else containers.each do |c| rows << [role.to_s, c['State'], c['Names'], c['Image']] end end end @ui.table(headers: %w[Role State Name Image], rows: rows) @ui.blank end # Dependencies if config[:dependencies]&.any? @ui.section 'Dependencies' rows = config[:dependencies].map do |name, acc_config| acc_service = "#{service_name}-#{name}" containers = docker.list(service: acc_service, all: true) running = containers.find { |c| c['State'] == 'running' } if running health = running['Status'].include?('healthy') ? '✓' : '' [name.to_s, 'running', acc_config[:image], running['ID'][0..11], health] else [name.to_s, 'stopped', acc_config[:image], '-', ''] end end @ui.table(headers: %w[Name State Image Container Health], rows: rows) @ui.blank end # TLS if config[:proxy][:hosts]&.any? @ui.section 'TLS' if caddy_status[:running] && caddy_status[:tls][:enabled] service_hosts = config[:proxy][:hosts] relevant_policy = caddy_status[:tls][:policies].find do |p| p[:subjects].intersect?(service_hosts) end if relevant_policy @ui.info 'Domains', (relevant_policy[:subjects] & service_hosts).join(', ') @ui.info 'Issuer', relevant_policy[:issuer] @ui.info 'Email', relevant_policy[:email] || '(not set)' else @ui.step '(not configured for this service)' end else @ui.step '(Caddy not running or TLS not configured)' end end ensure ssh.close end rescue Odysseus::Error => e @ui.error e. exit 1 end |
#validate(options = {}) ⇒ Object
Validate command
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/odysseus/cli/cli.rb', line 288 def validate( = {}) config_file = [:config] || 'deploy.yml' @ui.header "Validating #{config_file}" config = load_config(config_file) @ui.success 'Configuration is valid' @ui.info 'Service', config[:service] @ui.info 'Image', config[:image] @ui.info 'Servers', config[:servers].keys.join(', ') @ui.info 'Proxy', config[:proxy][:hosts]&.join(', ') @ui.info 'Dependencies', config[:dependencies].keys.join(', ') if config[:dependencies]&.any? rescue Odysseus::Error => e @ui.error "Validation failed: #{e.}" exit 1 end |