summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Cowie <jcowie@chef.io>2017-08-10 13:53:53 +0100
committerJon Cowie <jcowie@chef.io>2017-08-10 14:16:44 +0100
commit4ee933275c5ff635bad93aa6f3e5faa1513e2807 (patch)
tree16c29b2f42f40bfaedf2cade5bd51492610dd908
parent7372d0ece166ee0d5a3e25bf84861807995e58be (diff)
downloadchef-4ee933275c5ff635bad93aa6f3e5faa1513e2807.tar.gz
Pass json configuration to ShellSession class
This commit passes json configuration to ShellSession class and thusly into ChefClient object created by the ShellSession. This fixes an issue where runlists passed in via a json file using the -j flag would not be loaded when running chef-shell in client mode using the -z flag. Signed-off-by: Jon Cowie <jcowie@chef.io>
-rw-r--r--lib/chef/shell.rb1
-rw-r--r--lib/chef/shell/shell_session.rb8
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb
index b4c0277c57..40bdf01762 100644
--- a/lib/chef/shell.rb
+++ b/lib/chef/shell.rb
@@ -138,6 +138,7 @@ module Shell
def self.session
unless client_type.instance.node_built?
puts "Session type: #{client_type.session_type}"
+ client_type.instance.json_configuration = @json_attribs
client_type.instance.reset!
end
client_type.instance
diff --git a/lib/chef/shell/shell_session.rb b/lib/chef/shell/shell_session.rb
index 41d5bd64a0..dfed5372c1 100644
--- a/lib/chef/shell/shell_session.rb
+++ b/lib/chef/shell/shell_session.rb
@@ -38,7 +38,7 @@ module Shell
@session_type
end
- attr_accessor :node, :compile, :recipe, :run_context
+ attr_accessor :node, :compile, :recipe, :run_context, :json_configuration
attr_reader :node_attributes, :client
def initialize
@node_built = false
@@ -151,7 +151,7 @@ module Shell
def rebuild_node
Chef::Config[:solo_legacy_mode] = true
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -183,7 +183,7 @@ module Shell
def rebuild_node
# Tell the client we're chef solo so it won't try to contact the server
Chef::Config[:solo_legacy_mode] = true
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.load_node
@client.build_node
@@ -218,7 +218,7 @@ module Shell
def rebuild_node
# Make sure the client knows this is not chef solo
Chef::Config[:solo_legacy_mode] = false
- @client = Chef::Client.new(nil, Chef::Config[:shell_config])
+ @client = Chef::Client.new(json_configuration, Chef::Config[:shell_config])
@client.run_ohai
@client.register
@client.load_node