Class: Bosh::Director::Jobs::Helpers::ReleasesToDeletePicker
- Defined in:
- lib/bosh/director/jobs/helpers/releases_to_delete_picker.rb
Instance Method Summary collapse
-
#initialize(release_manager) ⇒ ReleasesToDeletePicker
constructor
A new instance of ReleasesToDeletePicker.
- #pick(releases_to_keep) ⇒ Object
Constructor Details
#initialize(release_manager) ⇒ ReleasesToDeletePicker
Returns a new instance of ReleasesToDeletePicker.
4 5 6 |
# File 'lib/bosh/director/jobs/helpers/releases_to_delete_picker.rb', line 4 def initialize(release_manager) @release_manager = release_manager end |
Instance Method Details
#pick(releases_to_keep) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bosh/director/jobs/helpers/releases_to_delete_picker.rb', line 8 def pick(releases_to_keep) unused_releases = @release_manager .get_all_releases .map do |release| release['release_versions'].reject! { |version| version['currently_deployed'] } release end unused_releases_to_delete = unused_releases .reject{ |release| release['release_versions'].empty? } .map do |release| release['release_versions'].pop(releases_to_keep) release end unused_releases_to_delete.map do |release| release['release_versions'].map do |version| {'name' => release['name'], 'version' => version['version']} end end.flatten end |