From 14a3100e41e9ba2449eab2faad16813db5bc6dcd Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Thu, 4 Feb 2016 16:47:33 +0100 Subject: [PATCH] simplify result value from profile check --- bin/inspec | 4 ++-- lib/inspec/profile.rb | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/inspec b/bin/inspec index 71ca0a4e8..b45e9386b 100755 --- a/bin/inspec +++ b/bin/inspec @@ -82,7 +82,7 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength # run check profile = Inspec::Profile.from_path(path, o) - success, result = profile.check + result = profile.check if opts['format'] == 'json' puts JSON.generate(result) @@ -101,7 +101,7 @@ class InspecCLI < Thor # rubocop:disable Metrics/ClassLength newline } end - exit 1 unless success + exit 1 unless result[:summary][:valid] end desc 'archive PATH', 'archive a profile to tar.gz (default) or zip' diff --git a/lib/inspec/profile.rb b/lib/inspec/profile.rb index 619212d82..32df15353 100644 --- a/lib/inspec/profile.rb +++ b/lib/inspec/profile.rb @@ -162,8 +162,11 @@ module Inspec } } + # profile is valid if we could not find any error + result[:summary][:valid] = result[:errors].empty? + @logger.info 'Control definitions OK.' if result[:warnings].empty? - [result[:errors].empty?, result] + result end def rules_count