mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
CFINSPEC-13: Adds the support to load the gem dependencies from dependent profiles.
Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
parent
e3ef2cb912
commit
b1ce116ebb
3 changed files with 15 additions and 3 deletions
|
@ -380,10 +380,23 @@ module Inspec
|
|||
@runner_context
|
||||
end
|
||||
|
||||
def collect_gem_dependencies(profile_context)
|
||||
gem_dependencies = []
|
||||
all_profiles = []
|
||||
profile_context.dependencies.list.values.each do |requirement|
|
||||
all_profiles << requirement.profile
|
||||
end
|
||||
all_profiles << self
|
||||
all_profiles.each do |profile|
|
||||
gem_dependencies << profile.metadata.gem_dependencies unless profile.metadata.gem_dependencies.empty?
|
||||
end
|
||||
gem_dependencies.flatten.uniq
|
||||
end
|
||||
|
||||
# Loads the required gems specified in the Profile's metadata file from default inspec gems path i.e. ~/.inspec/gems
|
||||
# else installs and loads them.
|
||||
def load_gem_dependencies
|
||||
gem_dependencies = metadata. gem_dependencies
|
||||
gem_dependencies = collect_gem_dependencies(load_libraries)
|
||||
gem_dependencies.each do |gem_data|
|
||||
dependency_loader = DependencyLoader.new
|
||||
gem_version = gem_data[:version].split[1] unless gem_data[:version].nil?
|
||||
|
|
|
@ -105,7 +105,7 @@ module Inspec
|
|||
|
||||
write_lockfile(profile) if @create_lockfile
|
||||
profile.locked_dependencies
|
||||
profile.load_gem_dependencies unless profile.metadata.gem_dependencies.empty?
|
||||
profile.load_gem_dependencies
|
||||
profile_context = profile.load_libraries
|
||||
|
||||
profile_context.dependencies.list.values.each do |requirement|
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
require "helper"
|
||||
require "inspec/dependency_loader"
|
||||
require "byebug"
|
||||
|
||||
describe "dependency_loader" do
|
||||
let(:config_dir_path) { File.expand_path "test/fixtures/config_dirs" }
|
||||
|
|
Loading…
Reference in a new issue