Module: Nucleus::Adapters::V1::Heroku::Data
- Included in:
- Nucleus::Adapters::V1::Heroku
- Defined in:
- lib/nucleus/adapters/v1/heroku/data.rb
Instance Method Summary collapse
- #deploy(application_id, file, file_compression_format) ⇒ Object
- #download(application_id, compression_format) ⇒ Object
- #rebuild(application_id) ⇒ Object
Instance Method Details
#deploy(application_id, file, file_compression_format) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nucleus/adapters/v1/heroku/data.rb', line 7 def deploy(application_id, file, file_compression_format) app = get("/apps/#{application_id}").body account = get('/account').body repo_name = "nucleus.app.repo.heroku.deploy.#{application_id}.#{SecureRandom.uuid}" # clone, extract, push and finally delete cloned repository (sync) with_ssh_key do GitDeployer.new(repo_name, app[:git_url], account[:email]).deploy(file, file_compression_format) end return unless application_state(app) == Enums::ApplicationStates::CREATED # instantly remove all initially added dynos to keep the 'deployed' state on first deployment log.debug 'state before deployment was \'created\', scale web to 0' scale_web(application_id, 0) end |
#download(application_id, compression_format) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/nucleus/adapters/v1/heroku/data.rb', line 23 def download(application_id, compression_format) # Only possible with git, not with HTTP builds app = get("/apps/#{application_id}").body if application_state(app) == Enums::ApplicationStates::CREATED fail Errors::SemanticAdapterRequestError, 'Application must be deployed before data can be downloaded' end # compress files to archive but exclude the .git repo repo_name = "nucleus.app.repo.heroku.download.#{application_id}.#{SecureRandom.uuid}" with_ssh_key do GitDeployer.new(repo_name, app[:git_url], nil).download(compression_format, true) end end |
#rebuild(application_id) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/nucleus/adapters/v1/heroku/data.rb', line 37 def rebuild(application_id) app = get("/apps/#{application_id}").body if application_state(app) == Enums::ApplicationStates::CREATED fail Errors::SemanticAdapterRequestError, 'Application must be deployed before data can be rebuild' end account = get('/account').body repo_name = "nucleus.app.repo.heroku.rebuild.#{application_id}.#{SecureRandom.uuid}" with_ssh_key do GitDeployer.new(repo_name, app[:git_url], account[:email]).trigger_build end # return with updated application application(application_id) end |