Class: VagrantPlugins::DigitalOcean::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Config
- Defined in:
- lib/vagrant-digitalocean/config.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#ca_path ⇒ Object
Returns the value of attribute ca_path.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#image ⇒ Object
Returns the value of attribute image.
-
#region ⇒ Object
Returns the value of attribute region.
-
#size ⇒ Object
Returns the value of attribute size.
-
#ssh_key_name ⇒ Object
Returns the value of attribute ssh_key_name.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
12 13 14 15 16 17 18 19 20 |
# File 'lib/vagrant-digitalocean/config.rb', line 12 def initialize @client_id = UNSET_VALUE @api_key = UNSET_VALUE @image = UNSET_VALUE @region = UNSET_VALUE @size = UNSET_VALUE @ca_path = UNSET_VALUE @ssh_key_name = UNSET_VALUE end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/vagrant-digitalocean/config.rb', line 5 def api_key @api_key end |
#ca_path ⇒ Object
Returns the value of attribute ca_path.
9 10 11 |
# File 'lib/vagrant-digitalocean/config.rb', line 9 def ca_path @ca_path end |
#client_id ⇒ Object
Returns the value of attribute client_id.
4 5 6 |
# File 'lib/vagrant-digitalocean/config.rb', line 4 def client_id @client_id end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/vagrant-digitalocean/config.rb', line 6 def image @image end |
#region ⇒ Object
Returns the value of attribute region.
7 8 9 |
# File 'lib/vagrant-digitalocean/config.rb', line 7 def region @region end |
#size ⇒ Object
Returns the value of attribute size.
8 9 10 |
# File 'lib/vagrant-digitalocean/config.rb', line 8 def size @size end |
#ssh_key_name ⇒ Object
Returns the value of attribute ssh_key_name.
10 11 12 |
# File 'lib/vagrant-digitalocean/config.rb', line 10 def ssh_key_name @ssh_key_name end |
Instance Method Details
#finalize! ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-digitalocean/config.rb', line 22 def finalize! @client_id = ENV['DO_CLIENT_ID'] if @client_id == UNSET_VALUE @api_key = ENV['DO_API_KEY'] if @api_key == UNSET_VALUE @image = 'Ubuntu 12.04 x64 Server' if @image == UNSET_VALUE @region = 'New York 1' if @region == UNSET_VALUE @size = '512MB' if @size == UNSET_VALUE @ca_path = nil if @ca_path == UNSET_VALUE @ssh_key_name = 'Vagrant' if @ssh_key_name == UNSET_VALUE end |
#validate(machine) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vagrant-digitalocean/config.rb', line 32 def validate(machine) errors = [] errors << I18n.t('vagrant_digital_ocean.config.client_id') if !@client_id errors << I18n.t('vagrant_digital_ocean.config.api_key') if !@api_key key = machine.config.ssh.private_key_path if !key errors << I18n.t('vagrant_digital_ocean.config.private_key') elsif !File.file?(File.("#{key}.pub", machine.env.root_path)) errors << I18n.t('vagrant_digital_ocean.config.public_key', { :key => "#{key}.pub" }) end { 'Digital Ocean Provider' => errors } end |