inspec/lib/resources/filesystem.rb
Miah Johnson 7b23fa479c Add correct supports platform to resources. (#2674)
* Add correct `supports platform` to resources.

Signed-off-by: Miah Johnson <miah@chia-pet.org>

* Remove 'os_family' and update platforms to specify what they did.

Signed-off-by: Miah Johnson <miah@chia-pet.org>

* Add esx and cisco to generic resources.

Signed-off-by: Jared Quick <jquick@chef.io>
2018-02-19 15:26:49 +01:00

31 lines
831 B
Ruby

module Inspec::Resources
class FileSystemResource < Inspec.resource(1)
name 'filesystem'
supports platform: 'linux'
desc 'Use the filesystem InSpec resource to test file system'
example "
describe filesystem('/') do
its('size') { should be >= 32000 }
end
"
attr_reader :partition
def initialize(partition)
@partition = partition
end
def size
@size ||= begin
cmd = inspec.command("df #{partition} --output=size")
raise Inspec::Exceptions::ResourceFailed, "Unable to get available space for partition #{partition}" if cmd.stdout.nil? || cmd.stdout.empty? || !cmd.exit_status.zero?
value = cmd.stdout.gsub(/\dK-blocks[\r\n]/, '').strip
value.to_i
end
end
def to_s
"Filesystem #{partition}"
end
end
end