summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/chef_class.rb16
-rw-r--r--lib/chef/knife/bootstrap.rb7
-rw-r--r--lib/chef/knife/core/bootstrap_context.rb14
3 files changed, 30 insertions, 7 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index bcb5eec4e4..2cb1e157c6 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -54,6 +54,10 @@ class Chef
#
attr_reader :run_context
+
+
+ attr_reader :bootstrap_context
+
# Register an event handler with user specified block
#
# @return[Chef::EventDispatch::Base] handler object
@@ -162,6 +166,17 @@ class Chef
@run_context = run_context
end
+
+ #
+ # Sets the bootstrap_context object
+ #
+ # @param bootstrap_context [Chef::BootstrapContext]
+ #
+ # @api private
+ def set_bootstrap_context(bootstrap_context)
+ @bootstrap_context = bootstrap_context
+ end
+
#
# Resets the internal state
#
@@ -173,6 +188,7 @@ class Chef
@resource_priority_map = nil
@provider_handler_map = nil
@resource_handler_map = nil
+ @bootstrap_context = nil
end
# @api private
diff --git a/lib/chef/knife/bootstrap.rb b/lib/chef/knife/bootstrap.rb
index a3f7d3a23c..71ae2f1d0d 100644
--- a/lib/chef/knife/bootstrap.rb
+++ b/lib/chef/knife/bootstrap.rb
@@ -522,7 +522,7 @@ class Chef
Knife::Core::WindowsBootstrapContext.new(config, config[:run_list], Chef::Config, secret)
else
require_relative "core/bootstrap_context"
- Knife::Core::BootstrapContext.new(config, config[:run_list], Chef::Config, secret)
+ Knife::Core::BootstrapContext.new(config, config[:run_list], Chef::Config, secret, connection.connection)
end
end
@@ -554,6 +554,7 @@ class Chef
plugin_create_instance!
$stdout.sync = true
connect!
+ set_bootstrap_context
register_client
content = render_template
@@ -564,6 +565,10 @@ class Chef
connection.del_file!(bootstrap_path) if connection && bootstrap_path
end
+ def set_bootstrap_context
+ Chef.set_bootstrap_context(bootstrap_context)
+ end
+
def register_client
# chef-vault integration must use the new client-side hawtness, otherwise to use the
# new client-side hawtness, just delete your validation key.
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index a70e463089..22e8aaa7da 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -35,12 +35,14 @@ class Chef
attr_accessor :client_pem
attr_accessor :config
attr_accessor :chef_config
-
- def initialize(config, run_list, chef_config, secret = nil)
- @config = config
- @run_list = run_list
- @chef_config = chef_config
- @secret = secret
+ attr_accessor :transport_connection
+
+ def initialize(config, run_list, chef_config, secret = nil, transport_connection = nil)
+ @config = config
+ @run_list = run_list
+ @chef_config = chef_config
+ @secret = secret
+ @transport_connection = transport_connection
end
def bootstrap_environment