Sha256: fb1289e9ef3e4e6ab07df21dc1a456407b5b01bca05e33983cb873da7f9944aa

Contents?: true

Size: 1.13 KB

Versions: 28

Compression:

Stored size: 1.13 KB

Contents

require "inspec/plugin/v1"

module Inspec
  class FetcherRegistry < PluginRegistry
    def resolve(target)
      if fetcher_specified?(target)
        super(target)
      else
        Inspec::Log.debug("Assuming default supermarket source for #{target}")
        super(with_default_fetcher(target))
      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

  Fetcher = FetcherRegistry.new

  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 "fetchers/local"
require "fetchers/url"
require "fetchers/git"

# TODO: Remove in 4.0 when Compliance fetcher plugin is created
require "plugins/inspec-compliance/lib/inspec-compliance/api"

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
inspec-core-4.18.39 lib/inspec/fetcher.rb
inspec-4.18.39 lib/inspec/fetcher.rb
inspec-core-4.18.38 lib/inspec/fetcher.rb
inspec-4.18.38 lib/inspec/fetcher.rb
inspec-core-4.18.24 lib/inspec/fetcher.rb
inspec-4.18.24 lib/inspec/fetcher.rb
inspec-core-4.18.0 lib/inspec/fetcher.rb
inspec-4.18.0 lib/inspec/fetcher.rb
inspec-core-4.17.17 lib/inspec/fetcher.rb
inspec-4.17.17 lib/inspec/fetcher.rb
inspec-core-4.17.15 lib/inspec/fetcher.rb
inspec-4.17.15 lib/inspec/fetcher.rb
inspec-core-4.17.14 lib/inspec/fetcher.rb
inspec-4.17.14 lib/inspec/fetcher.rb
inspec-core-4.17.11 lib/inspec/fetcher.rb
inspec-4.17.11 lib/inspec/fetcher.rb
inspec-core-4.17.7 lib/inspec/fetcher.rb
inspec-4.17.7 lib/inspec/fetcher.rb
inspec-core-4.16.0 lib/inspec/fetcher.rb
inspec-4.16.0 lib/inspec/fetcher.rb