Sha256: 41e2a97b193920c3992cd6df1ae4ac4266b263836a46e8f163a4fb8f5c73d525

Contents?: true

Size: 1.17 KB

Versions: 25

Compression:

Stored size: 1.17 KB

Contents

require "uri"
require "inspec/fetcher"
require "inspec/fetcher/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

25 entries across 25 versions & 2 rubygems

Version Path
inspec-core-4.24.8 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.23.15 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.23.11 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.23.10 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.23.4 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.22.22 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.22.8 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.22.1 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.22.0 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.21.3 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.21.1 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.20.10 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.20.6 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.20.2 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.19.2 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.19.0 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.18.114 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.18.111 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.18.108 lib/bundles/inspec-supermarket/target.rb
inspec-core-4.18.104 lib/bundles/inspec-supermarket/target.rb