Sha256: e1f839e9b4c1d78c33dae3f7287ba1d0e2ab6e199646ce7c96138d4896b7ff2f
Contents?: true
Size: 1.59 KB
Versions: 2
Compression:
Stored size: 1.59 KB
Contents
# frozen_string_literal: true module Bolt class Plugin class Task def hooks %i[validate_resolve_reference puppet_library resolve_reference] end def name 'task' end attr_accessor :pal, :executor, :inventory def initialize(context:, **_opts) @context = context end def run_task(opts) params = opts['parameters'] || {} options = { catch_errors: true } raise Bolt::ValidationError, "Task plugin requires that the 'task' is specified" unless opts['task'] task = @context.get_validated_task(opts['task'], params) result = @context.run_local_task(task, params, options).first raise Bolt::Error.new(result.error_hash['msg'], result.error_hash['kind']) if result.error_hash result end def validate_options(opts) raise Bolt::ValidationError, "Task plugin requires that the 'task' is specified" unless opts['task'] @context.get_validated_task(opts['task'], opts['parameters'] || {}) end alias validate_resolve_reference validate_options def resolve_reference(opts) result = run_task(opts) unless result.value.include?('value') raise Bolt::ValidationError, "Task result did not return 'value': #{result.value}" end result['value'] end def puppet_library(opts, target, apply_prep) params = opts['parameters'] || {} task = apply_prep.get_task(opts['task'], params) proc do apply_prep.run_task([target], task, params).first end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bolt-1.34.0 | lib/bolt/plugin/task.rb |
bolt-1.33.0 | lib/bolt/plugin/task.rb |