Sha256: cbbd0cc6245f7d65b7307cd4082e0f77f79ba9b7ff4a86df5df11b6aff651921

Contents?: true

Size: 1.17 KB

Versions: 36

Compression:

Stored size: 1.17 KB

Contents

# encoding: utf-8
# author: Dominik Richter
# author: Christoph Hartmann

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 = [: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 if !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

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

36 entries across 36 versions & 2 rubygems

Version Path
inspec-core-4.3.2 lib/inspec/fetcher.rb
inspec-4.3.2 lib/inspec/fetcher.rb
inspec-core-4.2.0.preview lib/inspec/fetcher.rb
inspec-4.2.0.preview lib/inspec/fetcher.rb
inspec-core-4.1.4.preview lib/inspec/fetcher.rb
inspec-4.1.4.preview lib/inspec/fetcher.rb
inspec-core-3.9.3 lib/inspec/fetcher.rb
inspec-3.9.3 lib/inspec/fetcher.rb
inspec-core-3.9.0 lib/inspec/fetcher.rb
inspec-3.9.0 lib/inspec/fetcher.rb
inspec-core-3.7.11 lib/inspec/fetcher.rb
inspec-3.7.11 lib/inspec/fetcher.rb
inspec-core-3.7.1 lib/inspec/fetcher.rb
inspec-3.7.1 lib/inspec/fetcher.rb
inspec-core-3.6.6 lib/inspec/fetcher.rb
inspec-3.6.6 lib/inspec/fetcher.rb
inspec-core-3.6.4 lib/inspec/fetcher.rb
inspec-3.6.4 lib/inspec/fetcher.rb
inspec-core-3.6.2 lib/inspec/fetcher.rb
inspec-3.6.2 lib/inspec/fetcher.rb