Class: VagrantPlugins::KeyManager::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



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

def initialize
  @extra_steps = nil
  @user_list = UNSET_VALUE
end

Instance Attribute Details

#extra_stepsObject

Returns the value of attribute extra_steps.



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

def extra_steps
  @extra_steps
end

#user_listObject

Returns the value of attribute user_list.



5
6
7
# File 'lib/vagrant-keymanager/config.rb', line 5

def user_list
  @user_list
end

Instance Method Details

#finalize!Object



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

def finalize!
  @user_list = [] if @user_list == UNSET_VALUE
  @user_list = [ "root", @user_list ].flatten.uniq
end

#validate(machine) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-keymanager/config.rb', line 17

def validate(machine)
  errors = []
  # errors << validate_bool('keymanager.enabled', @enabled)
  errors.compact!

  if !machine.config.keymanager.extra_steps.nil? &&
     !machine.config.keymanager.extra_steps.kind_of?(Proc)
    errors << I18n.t('vagrant_keymanager.config.not_a_proc', {
      :config_key => 'keymanager.extra_steps',
      :is_class   => extra_steps.class.to_s,
    })
  end

  if  !machine.config.keymanager.user_list.kind_of?(Array) &&
      !machine.config.keymanager.user_list.kind_of?(String)
    errors << I18n.t('vagrant_keymanager.config.not_an_array_or_string', {
      :config_key => 'keymanager.user_list',
      :is_class   => user_list.class.to_s,
    })
  end

  errors.compact!
  { "KeyManager configuration" => errors }
end