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.
-
#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.
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.
6 7 8 9 10 11 12 |
# File 'lib/vagrant-digitalocean/config.rb', line 6 def initialize @client_id = UNSET_VALUE @api_key = UNSET_VALUE @image = UNSET_VALUE @region = UNSET_VALUE @size = UNSET_VALUE end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
4 5 6 |
# File 'lib/vagrant-digitalocean/config.rb', line 4 def api_key @api_key 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.
4 5 6 |
# File 'lib/vagrant-digitalocean/config.rb', line 4 def image @image end |
#region ⇒ Object
Returns the value of attribute region.
4 5 6 |
# File 'lib/vagrant-digitalocean/config.rb', line 4 def region @region end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/vagrant-digitalocean/config.rb', line 4 def size @size end |
Instance Method Details
#finalize! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/vagrant-digitalocean/config.rb', line 14 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 x32 Server" if @image == UNSET_VALUE @region = "New York 1" if @region == UNSET_VALUE @size = "512MB" if @size == UNSET_VALUE end |
#validate(machine) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/vagrant-digitalocean/config.rb', line 22 def validate(machine) errors = [] errors << "Client ID required" if !@client_id errors << "API Key required" if !@api_key { "Digital Ocean Provider" => errors } end |