Merge pull request #1792 from chef/dr/platform-info

add platform info to json formatter
This commit is contained in:
Christoph Hartmann 2017-05-10 10:51:19 +02:00 committed by GitHub
commit ac5eb7a5e0
2 changed files with 19 additions and 0 deletions

View file

@ -114,6 +114,10 @@ class InspecRspecJson < InspecRspecMiniJson # rubocop:disable Metrics/ClassLengt
@output_hash[:other_checks] = examples_without_controls
@output_hash[:profiles] = profiles_info
@output_hash[:platform] = {
name: os(:name),
release: os(:release),
}
examples_with_controls.each do |example|
control = example2control(example)
@ -123,6 +127,11 @@ class InspecRspecJson < InspecRspecMiniJson # rubocop:disable Metrics/ClassLengt
private
def os(field)
return nil if @backend.nil?
@backend.os.params[field]
end
def all_unique_controls
Array(@all_controls).uniq
end

View file

@ -11,6 +11,15 @@ module Inspec
},
}.freeze
PLATFORM = {
'type' => 'object',
'additionalProperties' => false,
'properties' => {
'name' => { 'type' => 'string' },
'release' => { 'type' => 'string' },
},
}.freeze
# Tags are open right, with simple key-value associations and not restrictions
TAGS = { 'type' => 'object' }.freeze
@ -117,6 +126,7 @@ module Inspec
'type' => 'object',
'additionalProperties' => false,
'properties' => {
'platform' => PLATFORM,
'profiles' => {
'type' => 'array',
'items' => PROFILE,