Class: BoltServer::TransportApp
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- BoltServer::TransportApp
- Defined in:
- lib/bolt_server/transport_app.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ TransportApp
constructor
A new instance of TransportApp.
- #scrub_stack_trace(result) ⇒ Object
- #validate_schema(schema, body) ⇒ Object
Constructor Details
#initialize(config) ⇒ TransportApp
Returns a new instance of TransportApp.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bolt_server/transport_app.rb', line 17 def initialize(config) @config = config @schemas = { "ssh-run_task" => JSON.parse(File.read(File.join(__dir__, 'schemas', 'ssh-run_task.json'))), "winrm-run_task" => JSON.parse(File.read(File.join(__dir__, 'schemas', 'winrm-run_task.json'))) } shared_schema = JSON::Schema.new(JSON.parse(File.read(File.join(__dir__, 'schemas', 'task.json'))), Addressable::URI.parse("file:task")) JSON::Validator.add_schema(shared_schema) @executor = Bolt::Executor.new(0, load_config: false) @file_cache = BoltServer::FileCache.new(@config).setup super(nil) end |
Instance Method Details
#scrub_stack_trace(result) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/bolt_server/transport_app.rb', line 34 def scrub_stack_trace(result) if result.dig(:result, '_error', 'details', 'stack_trace') result[:result]['_error']['details'].reject! { |k| k == 'stack_trace' } end result end |
#validate_schema(schema, body) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/bolt_server/transport_app.rb', line 41 def validate_schema(schema, body) schema_error = JSON::Validator.fully_validate(schema, body) if schema_error.any? Bolt::Error.new("There was an error validating the request body.", 'boltserver/schema-error', schema_error) end end |