Skip to content

Commit

Permalink
add platform info to json formatter
Browse files Browse the repository at this point in the history
As part of #1661
  • Loading branch information
arlimus committed May 10, 2017
1 parent 1cecf4f commit b37922d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/inspec/rspec_json_formatter.rb
Expand Up @@ -114,6 +114,10 @@ def stop(notification)

@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)
Expand All @@ -123,6 +127,11 @@ def stop(notification)

private

def os(field)
return nil if @backend.nil?
@backend.os.params[field]
end

def all_unique_controls
Array(@all_controls).uniq
end
Expand Down
10 changes: 10 additions & 0 deletions lib/inspec/schema.rb
Expand Up @@ -11,6 +11,15 @@ class Schema # rubocop:disable Metrics/ClassLength
},
}.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

Expand Down Expand Up @@ -117,6 +126,7 @@ class Schema # rubocop:disable Metrics/ClassLength
'type' => 'object',
'additionalProperties' => false,
'properties' => {
'platform' => PLATFORM,
'profiles' => {
'type' => 'array',
'items' => PROFILE,
Expand Down

0 comments on commit b37922d

Please sign in to comment.