2016-02-08 19:06:07 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
|
|
|
|
|
|
|
require 'uri'
|
2016-02-22 01:18:02 +00:00
|
|
|
require 'inspec/fetcher'
|
|
|
|
require 'fetchers/url'
|
2016-02-08 19:06:07 +00:00
|
|
|
|
|
|
|
# InSpec Target Helper for Supermarket
|
|
|
|
module Supermarket
|
2016-02-22 01:18:02 +00:00
|
|
|
class Fetcher < Fetchers::Url
|
|
|
|
name 'supermarket'
|
|
|
|
priority 500
|
2016-02-08 19:06:07 +00:00
|
|
|
|
2016-02-22 01:18:02 +00:00
|
|
|
def self.resolve(target, opts = {})
|
2016-08-11 18:45:56 +00:00
|
|
|
return nil unless target.is_a?(String)
|
2016-02-22 01:18:02 +00:00
|
|
|
return nil unless URI(target).scheme == 'supermarket'
|
|
|
|
return nil unless Supermarket::API.exist?(target)
|
2016-02-19 08:12:25 +00:00
|
|
|
tool_info = Supermarket::API.find(target)
|
2016-02-08 19:06:07 +00:00
|
|
|
super(tool_info['tool_source_url'], opts)
|
2016-08-11 18:45:56 +00:00
|
|
|
rescue URI::Error
|
2016-02-22 01:18:02 +00:00
|
|
|
nil
|
2016-02-08 19:06:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
'Chef Compliance Profile Loader'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|