Class: Harbor::CLI::Deploy
- Inherits:
-
Object
- Object
- Harbor::CLI::Deploy
- Defined in:
- lib/harbor/cli/deploy.rb
Overview
Thin CLI wrapper over Harbor::Tools (the kernel). Every write operation (deploy, rollback, exec, maintenance) goes through the kernel so that audit log + event emission + lock + notifications behave identically across surfaces (cli / stdio MCP / http MCP / web UI).
Instance Method Summary collapse
- #deploy(project_name) ⇒ Object
- #exec_cmd(project_name, command) ⇒ Object
-
#initialize(options, config) ⇒ Deploy
constructor
A new instance of Deploy.
- #maintenance(project_name, state) ⇒ Object
- #rollback(project_name, version) ⇒ Object
Constructor Details
Instance Method Details
#deploy(project_name) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/harbor/cli/deploy.rb', line 16 def deploy(project_name) destination = @config.project(project_name).resolve_destination(@options["destination"]) $stdout.puts "Deploying #{project_name}#{destination ? ":#{destination}" : ""}..." output = @tools.call( "harbor_deploy", { "project" => project_name, "destination" => @options["destination"], "skip_push" => @options["skip_push"] }, actor: cli_actor, origin: :cli ) $stdout.puts output $stdout.puts "\nDeploy complete." rescue Harbor::Error => e $stderr.puts "#{e.class.name.split('::').last}: #{e.}" exit 1 end |
#exec_cmd(project_name, command) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/harbor/cli/deploy.rb', line 55 def exec_cmd(project_name, command) output = @tools.call( "harbor_exec", { "project" => project_name, "command" => command, "role" => @options["role"], "destination" => @options["destination"] }, actor: cli_actor, origin: :cli ) $stdout.puts output rescue Harbor::Error => e $stderr.puts "#{e.class.name.split('::').last}: #{e.}" exit 1 end |
#maintenance(project_name, state) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/harbor/cli/deploy.rb', line 73 def maintenance(project_name, state) enabled = %w[on true 1 enable].include?(state.downcase) output = @tools.call( "harbor_maintenance", { "project" => project_name, "enabled" => enabled, "destination" => @options["destination"] }, actor: cli_actor, origin: :cli ) $stdout.puts output $stdout.puts "Maintenance mode #{enabled ? 'enabled' : 'disabled'} for #{project_name}." rescue Harbor::Error => e $stderr.puts "#{e.class.name.split('::').last}: #{e.}" exit 1 end |
#rollback(project_name, version) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/harbor/cli/deploy.rb', line 36 def rollback(project_name, version) $stdout.puts "Rolling back #{project_name} to #{version}..." output = @tools.call( "harbor_rollback", { "project" => project_name, "version" => version, "destination" => @options["destination"] }, actor: cli_actor, origin: :cli ) $stdout.puts output $stdout.puts "\nRollback complete." rescue Harbor::Error => e $stderr.puts "#{e.class.name.split('::').last}: #{e.}" exit 1 end |