Method: Inspec::Resolver#fallback_to_archive_on_fetch_failure
- Defined in:
- lib/inspec/dependencies/resolver.rb
#fallback_to_archive_on_fetch_failure(dep) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/inspec/dependencies/resolver.rb', line 96 def fallback_to_archive_on_fetch_failure(dep) # This facility is intended to handle situations in which # the failing dependency *is* available in an archive that we have # available as a local dependency. We just need to find the archive and # alter the fetcher to refer to information in the archive. # Note that the vendor cache already should have the archive inflated # for this to work (see warm_cache_from_archives() from profile_vendor.rb) # Refs 4727 # This is where any existing archives should have been inflated - # that is, this is the vendor cache. Each archive would have a lockfile. cache_path = dep.cache.path = false Dir["#{cache_path}/*/inspec.lock"].each do |lockfile_path| lockfile = Inspec::Lockfile.from_file(lockfile_path) dep_set = Inspec::DependencySet.from_lockfile(lockfile, dep.opts) dep2 = dep_set.dep_list[dep.name] next unless dep2 if dep.opts.key?(:compliance) # This is ugly. The compliance fetcher works differently than the others, # and fails at the resolve stage, not the fetch stage. That means we can't # tweak the fetcher, we have to tweak the deps opts themselves. dep.opts[:sha256] = dep2.opts[:sha256] = true else # All other fetchers can be generalized, because they will survive their constructor. fetcher = dep.fetcher.fetcher # Not the CachedFetcher, but its fetcher made_a_change = fetcher.update_from_opts(dep2.opts) end ||= made_a_change end end |