diff options
author | sonots <sonots@gmail.com> | 2015-01-08 20:30:57 +0900 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2015-02-09 21:20:34 -0500 |
commit | 955bce9ed05d6c69a37c506dc9e24a6e407e1a4d (patch) | |
tree | 8c520fcab1b61a29660446fdf55bf2794f3fddb8 /lib/chef/application | |
parent | 0e13f128597cfa407f3d8377a12f4b67cf60af59 (diff) | |
download | chef-955bce9ed05d6c69a37c506dc9e24a6e407e1a4d.tar.gz |
add json_attribs option for chef-apply command
Diffstat (limited to 'lib/chef/application')
-rw-r--r-- | lib/chef/application/apply.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb index 22d835e876..42805001d8 100644 --- a/lib/chef/application/apply.rb +++ b/lib/chef/application/apply.rb @@ -43,6 +43,12 @@ class Chef::Application::Apply < Chef::Application :description => "Execute resources read from STDIN", :boolean => true + option :json_attribs, + :short => "-j JSON_ATTRIBS", + :long => "--json-attributes JSON_ATTRIBS", + :description => "Load attributes from a JSON file or URL", + :proc => nil + option :log_level, :short => "-l LEVEL", :long => "--log_level LEVEL", @@ -79,6 +85,8 @@ class Chef::Application::Apply < Chef::Application :default => !Chef::Platform.windows?, :description => "Use colored output, defaults to enabled" + attr_reader :json_attribs + def initialize super end @@ -88,6 +96,14 @@ class Chef::Application::Apply < Chef::Application Chef::Config.merge!(config) configure_logging configure_proxy_environment_variables + parse_json + end + + def parse_json + if Chef::Config[:json_attribs] + config_fetcher = Chef::ConfigFetcher.new(Chef::Config[:json_attribs]) + @json_attribs = config_fetcher.fetch_json + end end def read_recipe_file(file_name) @@ -106,7 +122,7 @@ class Chef::Application::Apply < Chef::Application def get_recipe_and_run_context Chef::Config[:solo] = true - @chef_client = Chef::Client.new + @chef_client = Chef::Client.new(@json_attribs) @chef_client.run_ohai @chef_client.load_node @chef_client.build_node |