Module: Nucleus::Adapters::V1::OpenshiftV2::Data
- Included in:
- Nucleus::Adapters::V1::OpenshiftV2
- Defined in:
- lib/nucleus/adapters/v1/openshift_v2/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 21 22 23 24 25 26 27 |
# File 'lib/nucleus/adapters/v1/openshift_v2/data.rb', line 7 def deploy(application_id, file, file_compression_format) app_id = app_id_by_name(application_id) app = get("/application/#{app_id}").body[:data] app_state = application_state(app) account = get('/user').body[:data] repo_name = "nucleus.app.repo.openshift_v2.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 # auto deployment could be active for applications not created with Nucleus return if app[:auto_deploy] build_deployment(app_id) return unless app_state == Enums::ApplicationStates::CREATED # and finally stop so we don't get to see the sample application and switch to the deployed state send_event(application_id, 'stop') end |
#download(application_id, compression_format) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/nucleus/adapters/v1/openshift_v2/data.rb', line 30 def download(application_id, compression_format) # Only possible with git app = get("/application/#{app_id_by_name(application_id)}").body[:data] 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.openshift_v2.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
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nucleus/adapters/v1/openshift_v2/data.rb', line 44 def rebuild(application_id) app_id = app_id_by_name(application_id) app = get("/application/#{app_id}").body[:data] if application_state(app) == Enums::ApplicationStates::CREATED fail Errors::SemanticAdapterRequestError, 'Application must be deployed before data can be rebuild' end account = get('/user').body[:data] repo_name = "nucleus.app.repo.openshift_v2.rebuild.#{application_id}.#{SecureRandom.uuid}" with_ssh_key do GitDeployer.new(repo_name, app[:git_url], account[:email]).trigger_build end # if auto deployment ist disabled, we must also trigger a clean build build_deployment(app_id) unless app[:auto_deploy] # return with updated application application(application_id) end |