Modify inspec json to use check_mode (#2435)

This modifies `inspec json` to make it not evaluate code inside of
`only_if` blocks.

Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
This commit is contained in:
Jerry Aldrich 2018-01-03 11:10:35 -06:00 committed by Dominik Richter
parent c4d678a1df
commit 972f3a6486
2 changed files with 8 additions and 0 deletions

View file

@ -36,6 +36,7 @@ class Inspec::InspecCLI < Inspec::BaseCLI
o = opts.dup
o[:ignore_supports] = true
o[:backend] = Inspec::Backend.create(target: 'mock://')
o[:check_mode] = true
profile = Inspec::Profile.for_target(target, o)
dst = o[:output].to_s

View file

@ -121,4 +121,11 @@ describe 'inspec json' do
out.exit_status.must_equal 0
end
end
describe 'inspec json with a profile containing only_if' do
it 'ignores the `only_if`' do
out = inspec('json ' + File.join(profile_path, 'only-if-os-nope'))
out.exit_status.must_equal 0
end
end
end