Sha256: 4291107ff87d95bbd58327d08c575d7a9e227eb529f51533009f0e71fbbff5bf

Contents?: true

Size: 1.24 KB

Versions: 189

Compression:

Stored size: 1.24 KB

Contents

# 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 = {})
      supermarket_uri, supermarket_server = if target.is_a?(String) && URI(target).scheme == 'supermarket'
                                              [target, Supermarket::API::SUPERMARKET_URL]
                                            elsif target.respond_to?(:key?) && target.key?(:supermarket)
                                              supermarket_server = target[:supermarket_url] || Supermarket::API::SUPERMARKET_URL
                                              ["supermarket://#{target[:supermarket]}", supermarket_server]
                                            end
      return nil unless supermarket_uri
      return nil unless Supermarket::API.exist?(supermarket_uri, supermarket_server)
      tool_info = Supermarket::API.find(supermarket_uri, supermarket_server)
      resolve_next(tool_info['tool_source_url'], opts)
    rescue URI::Error
      nil
    end

    def to_s
      'Chef Compliance Profile Loader'
    end
  end
end

Version data entries

189 entries across 189 versions & 2 rubygems

Version Path
inspec-core-4.3.2 lib/bundles/inspec-supermarket/target.rb
inspec-4.3.2 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.2.0.preview lib/bundles/inspec-supermarket/target.rb
inspec-4.2.0.preview lib/bundles/inspec-supermarket/target.rb
inspec-core-4.1.4.preview lib/bundles/inspec-supermarket/target.rb
inspec-4.1.4.preview lib/bundles/inspec-supermarket/target.rb
inspec-core-3.9.3 lib/bundles/inspec-supermarket/target.rb
inspec-3.9.3 lib/bundles/inspec-supermarket/target.rb
inspec-core-3.9.0 lib/bundles/inspec-supermarket/target.rb
inspec-3.9.0 lib/bundles/inspec-supermarket/target.rb
inspec-core-3.7.11 lib/bundles/inspec-supermarket/target.rb
inspec-3.7.11 lib/bundles/inspec-supermarket/target.rb
inspec-core-3.7.1 lib/bundles/inspec-supermarket/target.rb
inspec-3.7.1 lib/bundles/inspec-supermarket/target.rb
inspec-core-3.6.6 lib/bundles/inspec-supermarket/target.rb
inspec-3.6.6 lib/bundles/inspec-supermarket/target.rb
inspec-core-3.6.4 lib/bundles/inspec-supermarket/target.rb
inspec-3.6.4 lib/bundles/inspec-supermarket/target.rb
inspec-core-2.3.28 lib/bundles/inspec-supermarket/target.rb
inspec-2.3.28 lib/bundles/inspec-supermarket/target.rb