inspec/lib/bundles/inspec-supermarket/target.rb
Steven Danna 85cbe713d7
Add GitFetcher and rework Fetchers+SourceReaders
This adds a new git fetcher. In doing so, it also refactors how the
fetchers work a bit to better support fetchers that need to resolve
user-provided sources to fully specified sources appropriate for a
lockfile.

Signed-off-by: Steven Danna <steve@chef.io>
2016-09-09 14:14:36 +01:00

29 lines
687 B
Ruby

# encoding: utf-8
# author: Christoph Hartmann
# author: Dominik Richter
require 'uri'
require 'inspec/fetcher'
require 'fetchers/url'
# InSpec Target Helper for Supermarket
module Supermarket
class Fetcher < Inspec.fetcher(1)
name 'supermarket'
priority 500
def self.resolve(target, opts = {})
return nil unless target.is_a?(String)
return nil unless URI(target).scheme == 'supermarket'
return nil unless Supermarket::API.exist?(target)
tool_info = Supermarket::API.find(target)
resolve_next(tool_info['tool_source_url'], opts)
rescue URI::Error
nil
end
def to_s
'Chef Compliance Profile Loader'
end
end
end