Skip to content

Commit e95d6f5

Browse files
committed
Add glob support for modulepath
Recent versions of Puppet support glob expansion in the environment specified modulepath. This change is required for environments which take advantage of this support.
1 parent fd134ce commit e95d6f5

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/octocatalog-diff/catalog-util/fileresources.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def self.module_path(dir)
5959
result = []
6060
Regexp.last_match(1).split(/:/).map(&:strip).each do |path|
6161
next if path.start_with?('$')
62-
result << File.expand_path(path, dir)
62+
result.concat(Dir.glob(File.expand_path(path, dir)))
6363
end
6464
result
6565
else

spec/octocatalog-diff/tests/catalog-util/fileresources_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,22 @@ def catalog_from_fixture(path)
8383
it 'should return proper entries from environment.conf modulepath' do
8484
allow(File).to receive(:file?).with('/a/environment.conf').and_return(true)
8585
allow(File).to receive(:read).with('/a/environment.conf').and_return('modulepath=modules:site:$basemoduledir')
86+
allow(Dir).to receive(:glob).with('/a/modules').and_return(['/a/modules'])
87+
allow(Dir).to receive(:glob).with('/a/site').and_return(['/a/site'])
8688
result = OctocatalogDiff::CatalogUtil::FileResources.module_path('/a')
8789
expect(result).to eq(['/a/modules', '/a/site'])
8890
end
91+
92+
it 'should expand globs in modulepath, if present' do
93+
allow(File).to receive(:file?).with('/a/environment.conf').and_return(true)
94+
allow(File).to receive(:read).with('/a/environment.conf')
95+
.and_return('modulepath=modules:extra_mods/*/modules:$basemoduledir')
96+
allow(Dir).to receive(:glob).with('/a/modules').and_return(['/a/modules'])
97+
allow(Dir).to receive(:glob).with('/a/extra_mods/*/modules')
98+
.and_return(['/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
99+
result = OctocatalogDiff::CatalogUtil::FileResources.module_path('/a')
100+
expect(result).to eq(['/a/modules', '/a/extra_mods/a/modules', '/a/extra_mods/b/modules'])
101+
end
89102
end
90103

91104
context 'with mixed files and directories' do

0 commit comments

Comments
 (0)