Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-3310) Ensure plugin code for core types is available on local transport #3314

Merged
merged 1 commit into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/bolt/applicator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ def apply_ast(raw_ast, targets, options, plan_vars = {})
'catalog' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(catalog),
'plugins' => Puppet::Pops::Types::PSensitiveType::Sensitive.new(plugins),
'apply_settings' => @apply_settings,
# This should just be boltlib and modules dirs shipped with bolt packages
# The apply_catalog task uses them to load core types if they exist
'bolt_builtin_content' => @modulepath - @plugin_dirs,
'_task' => catalog_apply_task.name,
'_noop' => options[:noop]
}
Expand Down
13 changes: 13 additions & 0 deletions libexec/apply_catalog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@
$LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
end

# In the case we are applying on a bolt runner and using bundled-ruby over local transport
# we will want to load code shipped with bolt. This is last on the load path and therefore
# explicitly packaged plugins should take precedence
args['bolt_builtin_content'].each do |builtin_dir|
next unless Dir.exist?(builtin_dir)
Dir.foreach(builtin_dir) do |dir|
unless ['.', '..'].include? dir
full_path = File.join(builtin_dir, dir, 'lib')
$LOAD_PATH << full_path unless $LOAD_PATH.include?(full_path)
end
end
end

if (conn_info = args['_target'])
unless (type = conn_info['remote-transport'])
puts "Cannot execute a catalog for a remote target without knowing it's the remote-transport type."
Expand Down
Loading