Class: VagrantPlugins::ChefApply::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-chef-apply/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-chef-apply/config.rb', line 7

def initialize
  @path        = UNSET_VALUE
  @upload_path = UNSET_VALUE
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



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

def path
  @path
end

#upload_pathObject

Returns the value of attribute upload_path.



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

def upload_path
  @upload_path
end

Instance Method Details

#finalize!Object



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

def finalize!
  @path        = nil if @path == UNSET_VALUE
  @upload_path = "/tmp/vagrant-chef-apply.rb" if @upload_path == UNSET_VALUE
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-chef-apply/config.rb', line 17

def validate(machine)
  errors = _detected_errors

  # Validate that the parameters are properly set
  unless path
    errors << I18n.t("vagrant.provisioners.chef_apply.no_path_set")
  end

  # Validate the existence of a script to upload
  if path
    expanded_path = Pathname.new(path).expand_path(machine.env.root_path)
    if !expanded_path.file?
      errors << I18n.t("vagrant.provisioners.chef_apply.path_invalid",
                        :path => expanded_path)
    end
  end

  # There needs to be a path to upload the script to
  if !upload_path
    errors << I18n.t("vagrant.provisioners.chef_apply.upload_path_not_set")
  end
  
  { "chef_apply provisioner" => errors }
end