mirror of
https://github.com/inspec/inspec
synced 2024-12-26 04:53:24 +00:00
093600b85f
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
30 lines
906 B
Ruby
30 lines
906 B
Ruby
# encoding: utf-8
|
|
#
|
|
# This is heavily based on:
|
|
#
|
|
# OHAI https://github.com/chef/ohai
|
|
# by Adam Jacob, Chef Software Inc
|
|
#
|
|
|
|
class Vulcano::Plugins::Backend
|
|
module DetectDarwin
|
|
def detect_darwin
|
|
cmd = @backend.run_command('/usr/bin/sw_vers')
|
|
# TODO: print an error in this step of the detection,
|
|
# as it shouldnt happen
|
|
return false if cmd.exit_status != 0
|
|
# TODO: ditto on error
|
|
return false if cmd.stdout.empty?
|
|
|
|
name = cmd.stdout[/^ProductName:\s+(.+)$/, 1]
|
|
# TODO: ditto on error
|
|
return false if name.nil?
|
|
@platform[:name] = name.downcase.chomp.tr(' ', '_')
|
|
@platform[:release] = cmd.stdout[/^ProductVersion:\s+(.+)$/, 1]
|
|
@platform[:build] = cmd.stdout[/^BuildVersion:\s+(.+)$/, 1]
|
|
# TODO: keep for now due to backwards compatibility with serverspec
|
|
@platform[:family] = 'darwin'
|
|
true
|
|
end
|
|
end
|
|
end
|