Class: Bolt::Plugin::PluginContext
- Inherits:
-
Object
- Object
- Bolt::Plugin::PluginContext
- Defined in:
- lib/bolt/plugin.rb
Instance Method Summary collapse
- #boltdir ⇒ Object
- #get_validated_task(task_name, params = nil) ⇒ Object
-
#initialize(config, pal, plugins) ⇒ PluginContext
constructor
A new instance of PluginContext.
-
#run_local_task(task, params, options) ⇒ Object
By passing ‘_` keys in params the caller can send metaparams directly to the task _catch_errors must be passed as an executor option not a param.
- #validate_params(task_name, params) ⇒ Object
Constructor Details
#initialize(config, pal, plugins) ⇒ PluginContext
Returns a new instance of PluginContext.
42 43 44 45 46 |
# File 'lib/bolt/plugin.rb', line 42 def initialize(config, pal, plugins) @pal = pal @config = config @plugins = plugins end |
Instance Method Details
#boltdir ⇒ Object
117 118 119 |
# File 'lib/bolt/plugin.rb', line 117 def boltdir @config.boltdir.path end |
#get_validated_task(task_name, params = nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/bolt/plugin.rb', line 79 def get_validated_task(task_name, params = nil) with_a_compiler do |compiler| tasksig = compiler.task_signature(task_name) raise Bolt::Error.unknown_task(task_name) unless tasksig Bolt::Task::Run.validate_params(tasksig, params) if params Bolt::Task.new(tasksig.task_hash) end end |
#run_local_task(task, params, options) ⇒ Object
By passing ‘_` keys in params the caller can send metaparams directly to the task _catch_errors must be passed as an executor option not a param
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/bolt/plugin.rb', line 103 def run_local_task(task, params, ) # Make sure we're in a compiler to use the sensitive type with_a_compiler do |_comp| params = Bolt::Task::Run.wrap_sensitive(task, params) Bolt::Task::Run.run_task( task, empty_inventory.get_targets('localhost'), params, , serial_executor ) end end |
#validate_params(task_name, params) ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'lib/bolt/plugin.rb', line 90 def validate_params(task_name, params) with_a_compiler do |compiler| tasksig = compiler.task_signature(task_name) raise Bolt::Error.new("#{task_name} could not be found", 'bolt/plugin-error') unless tasksig Bolt::Task::Run.validate_params(tasksig, params) end nil end |