Class: Chef::Knife::SubcommandLoader::CustomManifestLoader
- Inherits:
-
Chef::Knife::SubcommandLoader
- Object
- Chef::Knife::SubcommandLoader
- Chef::Knife::SubcommandLoader::CustomManifestLoader
- Defined in:
- lib/chef/knife/core/custom_manifest_loader.rb
Overview
Load a subcommand from a user-supplied manifest file
Instance Attribute Summary collapse
-
#manifest ⇒ Object
Returns the value of attribute manifest.
Attributes inherited from Chef::Knife::SubcommandLoader
Instance Method Summary collapse
-
#find_subcommands_via_manifest ⇒ Object
If the user has created a ~/.chef/plugin_manifest.json file, we’ll use that instead of inspecting the on-system gems to find the plugins.
-
#initialize(chef_config_dir, plugin_manifest) ⇒ CustomManifestLoader
constructor
A new instance of CustomManifestLoader.
- #subcommand_files ⇒ Object
Methods inherited from Chef::Knife::SubcommandLoader
autogenerated_manifest?, #command_class_from, custom_manifest?, #find_longest_key, #find_subcommands_via_dirglob, for_config, #force_load, gem_glob_loader, #guess_category, #list_commands, #load_command, #load_commands, plugin_manifest, plugin_manifest?, plugin_manifest_path, #positional_arguments, #site_subcommands
Constructor Details
#initialize(chef_config_dir, plugin_manifest) ⇒ CustomManifestLoader
Returns a new instance of CustomManifestLoader.
28 29 30 31 |
# File 'lib/chef/knife/core/custom_manifest_loader.rb', line 28 def initialize(chef_config_dir, plugin_manifest) super(chef_config_dir) @manifest = plugin_manifest end |
Instance Attribute Details
#manifest ⇒ Object
Returns the value of attribute manifest.
27 28 29 |
# File 'lib/chef/knife/core/custom_manifest_loader.rb', line 27 def manifest @manifest end |
Instance Method Details
#find_subcommands_via_manifest ⇒ Object
If the user has created a ~/.chef/plugin_manifest.json file, we’ll use that instead of inspecting the on-system gems to find the plugins. The file format is expected to look like:
{ "plugins": {
"knife-ec2": {
"paths": [
"/home/alice/.rubymanagerthing/gems/knife-ec2-x.y.z/lib/chef/knife/ec2_server_create.rb",
"/home/alice/.rubymanagerthing/gems/knife-ec2-x.y.z/lib/chef/knife/ec2_server_delete.rb"
]
}
}
}
Extraneous content in this file is ignored. This is intentional so that we can adapt the file format for potential behavior changes to knife in the future.
50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/chef/knife/core/custom_manifest_loader.rb', line 50 def find_subcommands_via_manifest # Format of subcommand_files is "relative_path" (something you can # Kernel.require()) => full_path. The relative path isn't used # currently, so we just map full_path => full_path. subcommand_files = {} manifest["plugins"].each do |plugin_name, plugin_manifest| plugin_manifest["paths"].each do |cmd_path| subcommand_files[cmd_path] = cmd_path end end subcommand_files.merge(find_subcommands_via_dirglob) end |
#subcommand_files ⇒ Object
63 64 65 |
# File 'lib/chef/knife/core/custom_manifest_loader.rb', line 63 def subcommand_files @subcommand_files ||= (find_subcommands_via_manifest.values + site_subcommands).flatten.uniq end |