Sha256: c384a29611c9ed09622086059a6d899e2f99b22b5d8683624b30f4505dfd14e0

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

require "inspec/plugin/v1"

module Inspec
  class FetcherRegistry < PluginRegistry
    def resolve(target, opts = {})
      if fetcher_specified?(target)
        super(target, opts)
      else
        Inspec::Log.debug("Assuming default supermarket source for #{target}")
        super(with_default_fetcher(target), opts)
      end
    end

    NON_FETCHER_KEYS = %i{name version_constraint cwd backend cache sha256}.freeze
    def fetcher_specified?(target)
      # Only set a default for Hash-based (i.e. from
      # inspec.yml/inspec.lock) targets

      return true unless target.respond_to?(:keys)

      !(target.keys - NON_FETCHER_KEYS).empty?
    end

    def with_default_fetcher(target)
      target.merge({ supermarket: target[:name] })
    end
  end

  module Fetcher
    Registry = FetcherRegistry.new
  end

  def self.fetcher(version)
    if version != 1
      raise "Only fetcher version 1 is supported!"
    end

    Inspec::Plugins::Fetcher
  end
end

# TODO: remove. require up, not down.
require "inspec/fetcher/local"
require "inspec/fetcher/url"
require "inspec/fetcher/git"
require "plugins/inspec-compliance/lib/inspec-compliance/api"

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
inspec-core-6.8.11 lib/inspec/fetcher.rb
inspec-core-5.22.58 lib/inspec/fetcher.rb
inspec-core-5.22.55 lib/inspec/fetcher.rb
inspec-core-6.8.1 lib/inspec/fetcher.rb
inspec-core-5.22.40 lib/inspec/fetcher.rb
inspec-core-6.6.0 lib/inspec/fetcher.rb
inspec-core-5.22.36 lib/inspec/fetcher.rb
inspec-core-5.22.29 lib/inspec/fetcher.rb
inspec-core-4.56.58 lib/inspec/fetcher.rb
inspec-core-5.22.3 lib/inspec/fetcher.rb
inspec-core-5.21.29 lib/inspec/fetcher.rb
inspec-core-5.18.14 lib/inspec/fetcher.rb
inspec-core-5.17.4 lib/inspec/fetcher.rb
inspec-core-5.14.0 lib/inspec/fetcher.rb
inspec-core-4.56.20 lib/inspec/fetcher.rb
inspec-core-5.12.2 lib/inspec/fetcher.rb
inspec-core-5.10.5 lib/inspec/fetcher.rb
inspec-core-4.56.19 lib/inspec/fetcher.rb
inspec-core-5.7.9 lib/inspec/fetcher.rb
inspec-core-4.56.17 lib/inspec/fetcher.rb