Class: VagrantFogBoxStorage::Config
- Inherits:
-
Vagrant::Config::Base
- Object
- Vagrant::Config::Base
- VagrantFogBoxStorage::Config
- Defined in:
- lib/vagrant-fog-box-storage/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #box_directory ⇒ Object
- #box_url ⇒ Object
- #cloud_directories ⇒ Object
- #cloud_storage ⇒ Object
- #directory_files ⇒ Object
- #expiry_time ⇒ Object
- #is_used? ⇒ Boolean
- #validate(env, errors) ⇒ Object
Class Method Details
.key_names ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 10 def self.key_names [ :provider, :access_key_id, :secret_access_key, :bucket_name, :box_file_name ] end |
Instance Method Details
#box_directory ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 46 def box_directory directory = cloud_directories.get(self.bucket_name) raise CloudStorageBucketNotFound.new("#{self.bucket_name} does not exist") if !directory directory end |
#box_url ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 64 def box_url files = directory_files() url = files.get_https_url(self.box_file_name, expiry_time) url end |
#cloud_directories ⇒ Object
42 43 44 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 42 def cloud_directories cloud_storage.directories end |
#cloud_storage ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 30 def cloud_storage if is_used? provider_name = self.provider.to_s.downcase @cloud_storage ||= Fog::Storage.new({ :provider => self.provider, :"#{provider_name}_access_key_id" => self.access_key_id, :"#{provider_name}_secret_access_key" => self.secret_access_key }) end end |
#directory_files ⇒ Object
54 55 56 57 58 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 54 def directory_files directory = box_directory() directory.files end |
#expiry_time ⇒ Object
60 61 62 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 60 def expiry_time Time.now + 3600 end |
#is_used? ⇒ Boolean
24 25 26 27 28 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 24 def is_used? self.class.key_names.any? do |name| !self.send(name).nil? end end |
#validate(env, errors) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/vagrant-fog-box-storage/config.rb', line 72 def validate(env, errors) if is_used? errors.add('missing provider') if !self.provider errors.add('missing access_key_id') if !self.access_key_id errors.add('missing secret_access_key') if !self.secret_access_key errors.add('missing bucket_name') if !self.bucket_name errors.add('missing box_file_name') if !self.box_file_name end end |