Class: VagrantPlugins::Omnibus::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Omnibus::Config
- Defined in:
- lib/vagrant-omnibus/config.rb
Overview
Instance Attribute Summary collapse
-
#cache_packages ⇒ String
The version of Chef to install.
-
#chef_version ⇒ String
The version of Chef to install.
-
#install_url ⇒ String
The version of Chef to install.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#validate!(machine) ⇒ Object
Performs validation and immediately raises an exception for any detected errors.
Constructor Details
#initialize ⇒ Config
32 33 34 35 36 37 |
# File 'lib/vagrant-omnibus/config.rb', line 32 def initialize @chef_version = UNSET_VALUE @install_url = UNSET_VALUE @cache_packages = UNSET_VALUE @logger = Log4r::Logger.new('vagrantplugins::omnibus::config') end |
Instance Attribute Details
#cache_packages ⇒ String
30 31 32 |
# File 'lib/vagrant-omnibus/config.rb', line 30 def cache_packages @cache_packages end |
#chef_version ⇒ String
30 31 32 |
# File 'lib/vagrant-omnibus/config.rb', line 30 def chef_version @chef_version end |
#install_url ⇒ String
30 31 32 |
# File 'lib/vagrant-omnibus/config.rb', line 30 def install_url @install_url end |
Instance Method Details
#finalize! ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/vagrant-omnibus/config.rb', line 39 def finalize! if @chef_version == UNSET_VALUE @chef_version = nil elsif @chef_version.to_s == 'latest' # resolve `latest` to a real version @chef_version = retrieve_latest_chef_version end # enable caching by default @cache_packages = true if @cache_packages == UNSET_VALUE # nil means default install.sh|msi @install_url = nil if @install_url == UNSET_VALUE end |
#validate!(machine) ⇒ Object
Performs validation and immediately raises an exception for any detected errors.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/vagrant-omnibus/config.rb', line 59 def validate!(machine) finalize! errors = [] if !chef_version.nil? && !valid_chef_version?(chef_version) msg = <<-EOH '#{ chef_version }' is not a valid version of Chef. A list of valid versions can be found at: http://www.opscode.com/chef/install/ EOH errors << msg end if errors.any? rendered_errors = Vagrant::Util::TemplateRenderer.render( 'config/validation_failed', errors: { 'vagrant-omnibus' => errors } ) fail Vagrant::Errors::ConfigInvalid, errors: rendered_errors end end |