Module: Kitchen::Provisioner::ChefAliasLoader
- Defined in:
- lib/kitchen/provisioner/chef_alias_loader.rb
Overview
Helpers for the chef_* alias provisioners shipped by kitchen-cinc.
The chef_* names have a priority order across kitchen-* gems: kitchen-chef-enterprise > kitchen-cinc > kitchen-omnibus-chef. When a higher-priority gem is installed, our chef_* alias should yield to it rather than claim the constant. Users who explicitly want kitchen-cinc behavior should use the cinc_* names in kitchen.yml.
Class Method Summary collapse
-
.defer_to_enterprise(const_name) ⇒ Boolean
If kitchen-chef-enterprise is installed, attempt to load its implementation of the named provisioner from its absolute path (bypasses $LOAD_PATH ambiguity).
- .enterprise_spec ⇒ Object
Class Method Details
.defer_to_enterprise(const_name) ⇒ Boolean
If kitchen-chef-enterprise is installed, attempt to load its implementation of the named provisioner from its absolute path (bypasses $LOAD_PATH ambiguity). Returns true if enterprise’s version was loaded and now owns the constant; false otherwise, in which case the caller should register its own subclass.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kitchen/provisioner/chef_alias_loader.rb', line 39 def defer_to_enterprise(const_name) spec = enterprise_spec return false unless spec file_name = Kitchen::Util.snake_case(const_name.to_s) path = File.join(spec.gem_dir, "lib", "kitchen", "provisioner", "#{file_name}.rb") return false unless File.exist?(path) require path Kitchen::Provisioner.const_defined?(const_name, false) end |
.enterprise_spec ⇒ Object
51 52 53 54 55 |
# File 'lib/kitchen/provisioner/chef_alias_loader.rb', line 51 def enterprise_spec Gem::Specification.find_by_name("kitchen-chef-enterprise") rescue Gem::LoadError nil end |