Class: ConsulBridge::DownloadMasters
- Defined in:
- lib/consul_bridge/download_masters.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(bucket:) ⇒ DownloadMasters
constructor
A new instance of DownloadMasters.
Methods inherited from Base
Constructor Details
#initialize(bucket:) ⇒ DownloadMasters
Returns a new instance of DownloadMasters.
8 9 10 |
# File 'lib/consul_bridge/download_masters.rb', line 8 def initialize(bucket:) self.bucket = bucket end |
Instance Attribute Details
#bucket ⇒ Object
Returns the value of attribute bucket.
6 7 8 |
# File 'lib/consul_bridge/download_masters.rb', line 6 def bucket @bucket end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/consul_bridge/download_masters.rb', line 12 def call puts "Downloading master ips from bucket #{self.bucket}" master_ips = [] storage = Fog::Storage.new provider: 'AWS', use_iam_profile: true bucket = storage.directories.get(self.bucket) bucket.files.each do |file| master_ips << [file.last_modified, file.key] end master_ips = master_ips.sort.reverse.collect { |file| file[1] } OpenStruct.new( master_ips: master_ips ) end |