Class: Berkshelf::Vagrant::Config
- Inherits:
-
Vagrant::Config::Base
- Object
- Vagrant::Config::Base
- Berkshelf::Vagrant::Config
- Defined in:
- lib/berkshelf/vagrant/config.rb
Overview
Instance Attribute Summary collapse
-
#berksfile_path ⇒ String
Path to the Berksfile to use with Vagrant.
-
#except ⇒ Array<Symbol>
Cookbooks in all other groups except for these will be installed and copied to Vagrant’s shelf.
-
#only ⇒ Array<Symbol>
Only cookbooks in these groups will be installed and copied to Vagrant’s shelf.
Instance Method Summary collapse
- #client_key=(value) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(env, errors) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 |
# File 'lib/berkshelf/vagrant/config.rb', line 20 def initialize @berksfile_path = File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME) @except = Array.new @only = Array.new end |
Instance Attribute Details
#berksfile_path ⇒ String
Returns path to the Berksfile to use with Vagrant.
8 9 10 |
# File 'lib/berkshelf/vagrant/config.rb', line 8 def berksfile_path @berksfile_path end |
#except ⇒ Array<Symbol>
Returns cookbooks in all other groups except for these will be installed and copied to Vagrant’s shelf.
18 19 20 |
# File 'lib/berkshelf/vagrant/config.rb', line 18 def except @except end |
#only ⇒ Array<Symbol>
Returns only cookbooks in these groups will be installed and copied to Vagrant’s shelf.
13 14 15 |
# File 'lib/berkshelf/vagrant/config.rb', line 13 def only @only end |
Instance Method Details
#client_key=(value) ⇒ Object
32 33 34 |
# File 'lib/berkshelf/vagrant/config.rb', line 32 def client_key=(value) @client_key = File.(value) end |
#validate(env, errors) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/berkshelf/vagrant/config.rb', line 36 def validate(env, errors) if !except.empty? && !only.empty? errors.add("A value for berkshelf.empty and berkshelf.only cannot both be defined.") end if Berkshelf::Vagrant.chef_client?(env.config.global) if Berkshelf::Config.instance.chef.node_name.nil? errors.add("A configuration must be set for chef.node_name when using the chef_client provisioner. Run 'berks configure' or edit your configuration.") end if Berkshelf::Config.instance.chef.client_key.nil? errors.add("A configuration must be set for chef.client_key when using the chef_client provisioner. Run 'berks configure' or edit your configuration.") end end end |