mirror of
https://github.com/inspec/inspec
synced 2024-11-24 13:43:09 +00:00
33 lines
793 B
Ruby
33 lines
793 B
Ruby
|
# encoding: utf-8
|
||
|
# author: Christoph Hartmann
|
||
|
# author: Dominik Richter
|
||
|
|
||
|
require 'uri'
|
||
|
|
||
|
# InSpec Target Helper for Supermarket
|
||
|
module Supermarket
|
||
|
class SupermarketHelper < Inspec::Targets::UrlHelper
|
||
|
def handles?(profile)
|
||
|
# check for local scheme supermarket://
|
||
|
return unless URI(profile).scheme == 'supermarket'
|
||
|
|
||
|
# verifies that the target e.g base/ssh exists
|
||
|
Supermarket::API.exist?(profile)
|
||
|
rescue URI::Error => _e
|
||
|
false
|
||
|
end
|
||
|
|
||
|
# generates proper url
|
||
|
def resolve(profile, opts = {})
|
||
|
tool_info = Supermarket::API.find(profile)
|
||
|
super(tool_info['tool_source_url'], opts)
|
||
|
end
|
||
|
|
||
|
def to_s
|
||
|
'Chef Compliance Profile Loader'
|
||
|
end
|
||
|
end
|
||
|
|
||
|
Inspec::Targets.add_module('supermarket', Supermarket::SupermarketHelper.new)
|
||
|
end
|