Class: Ey::Core::Cli::Deploy
- Inherits:
-
Subcommand
- Object
- Belafonte::App
- Subcommand
- Ey::Core::Cli::Deploy
- Includes:
- Helpers::LogStreaming
- Defined in:
- lib/ey-core/cli/deploy.rb
Instance Method Summary collapse
Methods included from Helpers::LogStreaming
#finished_request, #stream_deploy_log
Methods inherited from Subcommand
#handle_core_error, #run_handle, #setup
Methods included from Helpers::Core
#core_account, #core_accounts, #core_application_for, #core_applications, #core_client, #core_environment_for, #core_environment_variables, #core_environments, #core_operator_and_environment_for, #core_server_for, #core_url, #core_yaml, #eyrc_yaml, included, #longest_length_by_name, #operator, #unauthenticated_core_client, #write_core_yaml
Instance Method Details
#handle ⇒ Object
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 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ey-core/cli/deploy.rb', line 60 def handle operator, environment = core_operator_and_environment_for(self.) if operator.is_a?(Ey::Core::Client::Account) abort <<-EOF Found account #{operator.name} but requested account #{option(:account)}. Use the ID of the account instead of the name. This can be retrieved by running "ey-core accounts". EOF .red unless operator.name == option(:account) || operator.id == option(:account) end unless environment abort "Unable to locate environment #{option[:environment]} in #{operator.name}".red end unless option(:account) self..merge!(environment: environment) end app = core_application_for(environment, self.) = {verbose: switch_active?(:verbose), cli_args: ARGV} latest_deploy = nil if [:serverside_version] .merge!(serverside_version: option(:serverside_version)) end if [:ref] .merge!(ref: option(:ref)) else puts "--ref not provided, checking latest deploy...".yellow latest_deploy ||= environment.latest_deploy(app) if latest_deploy && latest_deploy.ref [:ref] = latest_deploy.ref else raise "--ref is required (HEAD is the typical choice)" end end if (option(:migrate) || switch_active?(:no_migrate)) .merge!(migrate_command: option(:migrate)) if option(:migrate) .merge!(migrate_command: nil) if switch_active?(:no_migrate) else puts "missing migrate option (--migrate or --no-migrate), checking latest deploy...".yellow latest_deploy ||= environment.latest_deploy(app) if latest_deploy .merge!(migrate_command: (latest_deploy.migrate && latest_deploy.migrate_command) || nil) else raise "either --migrate or --no-migrate needs to be specified" end end request = environment.deploy(app, ) puts <<-EOF Deploy started to environment: #{environment.name} with application: #{app.name} Request ID: #{request.id} EOF ap request ap request.resource if switch_active?(:no_wait) puts("Deploy started".green + " (use status command with --tail to view output)") else stream_deploy_log(request) end end |