Module: VMC::KNIFE::Cli
- Included in:
- Cli::Command::Knife, Cli::Command::Knifeapps, Cli::Command::Knifemisc
- Defined in:
- lib/vmc_knife/commands/knife_cmds.rb,
lib/vmc_knife/version.rb
Overview
Commands for vmc_knife.
Constant Summary collapse
- VERSION =
This version number is used as the RubyGem release version.
'0.0.68'
Instance Method Summary collapse
-
#load_manifest(manifest_file_path = nil) ⇒ Object
loads the manifest file.
Instance Method Details
#load_manifest(manifest_file_path = nil) ⇒ Object
loads the manifest file. when the path is not specified, look in the current directory. when the path is a directory, look for the first json file it can find. if it still find nothing then use the default which is the value of the environment variable VMC_KNIFE_DEFAULT_RECIPE the json file actually loaded is set as the attribute @manifest_path
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vmc_knife/commands/knife_cmds.rb', line 10 def load_manifest(manifest_file_path=nil) was_nil = true if manifest_file_path.nil? manifest_file_path = Dir.pwd if manifest_file_path.nil? if File.directory? manifest_file_path #look for the first .json file if possible that is not an expanded.json Dir.glob(File.join(manifest_file_path,"*.json")).each do |file| @manifest_path = file if VMC::Cli::Config.trace display "Using the manifest #{@manifest_path}" end return VMC::KNIFE::JSON_EXPANDER. @manifest_path end if was_nil && !ENV['VMC_KNIFE_DEFAULT_RECIPE'].nil? raise "Can't load the default recipe VMC_KNIFE_DEFAULT_RECIPE=#{ENV['VMC_KNIFE_DEFAULT_RECIPE']}" unless File.exists? ENV['VMC_KNIFE_DEFAULT_RECIPE'] load_manifest ENV['VMC_KNIFE_DEFAULT_RECIPE'] else raise "Unable to find a *.json file in #{manifest_file_path}" end else @manifest_path = manifest_file_path return VMC::KNIFE::JSON_EXPANDER. @manifest_path end end |