Class: VagrantPlugins::DigitalOcean::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-digitalocean/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

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_keyObject

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_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/vagrant-digitalocean/config.rb', line 4

def client_id
  @client_id
end

#imageObject

Returns the value of attribute image.



4
5
6
# File 'lib/vagrant-digitalocean/config.rb', line 4

def image
  @image
end

#regionObject

Returns the value of attribute region.



4
5
6
# File 'lib/vagrant-digitalocean/config.rb', line 4

def region
  @region
end

#sizeObject

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