mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
safeguard against empty backends
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
This commit is contained in:
parent
de27b3d8e9
commit
40784c7c8e
3 changed files with 14 additions and 6 deletions
|
@ -73,6 +73,8 @@ class VulcanoCLI < Thor
|
|||
runner = Vulcano::Runner.new(options[:id], options)
|
||||
runner.add_tests(tests)
|
||||
runner.run
|
||||
rescue RuntimeError => e
|
||||
puts e.message
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -6,6 +6,11 @@ module Vulcano
|
|||
|
||||
attr_reader :rules, :only_ifs
|
||||
def initialize profile_id, backend, profile_registry: {}, only_ifs: []
|
||||
if backend.nil?
|
||||
raise "ProfileContext is initiated with a backend == nil. " +
|
||||
"This is a backend error which must be fixed upstream."
|
||||
end
|
||||
|
||||
@profile_id = profile_id
|
||||
@rules = profile_registry
|
||||
@only_ifs = only_ifs
|
||||
|
|
|
@ -25,27 +25,28 @@ module Vulcano
|
|||
@rules = []
|
||||
@profile_id = profile_id
|
||||
@conf = Vulcano::Backend.target_config(conf)
|
||||
configure_output
|
||||
configure_backend
|
||||
end
|
||||
|
||||
def configure_output
|
||||
# RSpec.configuration.output_stream = $stdout
|
||||
# RSpec.configuration.error_stream = $stderr
|
||||
RSpec.configuration.add_formatter(:json)
|
||||
end
|
||||
|
||||
def configure_backend
|
||||
# specinfra
|
||||
backend_name = @conf[:backend] || 'exec'
|
||||
backend_class = Vulcano::Backend.registry[backend_name]
|
||||
if backend_class.nil?
|
||||
puts "Can't find command backend '#{backend_name}'."
|
||||
return
|
||||
raise "Can't find command backend '#{backend_name}'."
|
||||
end
|
||||
|
||||
# create the backend based on the config
|
||||
@backend = backend_class.new(@conf.dup)
|
||||
end
|
||||
|
||||
def select_backend( conf )
|
||||
|
||||
end
|
||||
|
||||
def add_tests(tests)
|
||||
items = tests.map do |test|
|
||||
Vulcano::Targets.resolve(test)
|
||||
|
|
Loading…
Add table
Reference in a new issue