Class: VagrantPlugins::TiktalikVagrant::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-tiktalik/config.rb', line 14

def initialize
  @api_key    = UNSET_VALUE
  @image      = UNSET_VALUE
  @size       = UNSET_VALUE
  @ssh_key    = UNSET_VALUE
  @api_secret = UNSET_VALUE
  @ca_file    = UNSET_VALUE
  @networks   = UNSET_VALUE
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



6
7
8
# File 'lib/vagrant-tiktalik/config.rb', line 6

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



10
11
12
# File 'lib/vagrant-tiktalik/config.rb', line 10

def api_secret
  @api_secret
end

#ca_fileObject

Returns the value of attribute ca_file.



11
12
13
# File 'lib/vagrant-tiktalik/config.rb', line 11

def ca_file
  @ca_file
end

#imageObject

Returns the value of attribute image.



7
8
9
# File 'lib/vagrant-tiktalik/config.rb', line 7

def image
  @image
end

#networksObject

Returns the value of attribute networks.



12
13
14
# File 'lib/vagrant-tiktalik/config.rb', line 12

def networks
  @networks
end

#sizeObject

Returns the value of attribute size.



8
9
10
# File 'lib/vagrant-tiktalik/config.rb', line 8

def size
  @size
end

#ssh_keyObject

Returns the value of attribute ssh_key.



9
10
11
# File 'lib/vagrant-tiktalik/config.rb', line 9

def ssh_key
  @ssh_key
end

Instance Method Details

#finalize!Object



24
25
26
27
28
29
30
31
32
# File 'lib/vagrant-tiktalik/config.rb', line 24

def finalize!
  @api_key    = ENV['TIKTALIK_API_KEY'] if @api_key == UNSET_VALUE
  @image      = nil if @image == UNSET_VALUE
  @size       = 0.5 if @size == UNSET_VALUE
  @ssh_key    = nil if @ssh_key == UNSET_VALUE
  @api_secret = ENV['TIKTALIK_API_SECRET'] if @api_secret == UNSET_VALUE
  @ca_file    = nil if @ca_file == UNSET_VALUE
  @networks   = nil if @networks == UNSET_VALUE
end

#validate(machine) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/vagrant-tiktalik/config.rb', line 34

def validate(machine)
  errors = []

  errors << I18n.t("vagrant_tiktalik.config.api_key_required") if config.api_key.nil?
  errors << I18n.t("vagrant_tiktalik.config.api_secret_required") if config.api_secret.nil?
  errors << I18n.t("vagrant_tiktalik.config.image_required") if config.image.nil?
  errors << I18n.t("vagrant_tiktalik.config.ssh_key_required") if !@ssh_key

  # TODO validate network

  { "Tiktalik Provider" => errors }
end