Skip to content

Commit

Permalink
Merge pull request #2065 from puppetlabs/FACT-2781
Browse files Browse the repository at this point in the history
(FACT-2781) Fix filesystems on osx
  • Loading branch information
oanatmaria authored Sep 7, 2020
2 parents 7362072 + b559238 commit 4d0541a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 1 addition & 5 deletions lib/facter/resolvers/macosx/filesystems_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ def post_resolve(fact_name)

def read_filesystems(fact_name)
output = Facter::Core::Execution.execute('mount', logger: log)
filesystems = []
output.each_line do |line|
filesystem = line.match(/\(([a-z]+)\,*/).to_s
filesystems << filesystem[1..-2]
end
filesystems = output.scan(/\(([a-z]+)\,*/).flatten
@fact_list[:macosx_filesystems] = filesystems.uniq.sort.join(',')
@fact_list[fact_name]
end
Expand Down
4 changes: 2 additions & 2 deletions spec/facter/resolvers/macosx/filesystems_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
before do
filesystems_resolver.instance_variable_set(:@log, log_spy)
allow(Facter::Core::Execution).to receive(:execute).with('mount', logger: log_spy)
.and_return(load_fixture('macosx_filesystems'))
.and_return(load_fixture('macosx_filesystems').read)
end

describe '#call_the_resolver' do
let(:filesystems) { 'apfs,autofs,devfs' }
let(:filesystems) { 'apfs,autofs,devfs,vmhgfs' }

it 'returns systems' do
expect(filesystems_resolver.resolve(:macosx_filesystems)).to eq(filesystems)
Expand Down
9 changes: 5 additions & 4 deletions spec/fixtures/macosx_filesystems
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/dev/disk1s1 on / (apfs, local, journaled)
/dev/disk1s5 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s4 on /private/var/vm (apfs, local, noexec, journaled, noatime, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s1 on /System/Volumes/Data (apfs, local, journaled, nobrowse)
/dev/disk1s4 on /private/var/vm (apfs, local, journaled, nobrowse)
map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
.host:/VMware Shared Folders on /Volumes/VMware Shared Folders (vmhgfs)

0 comments on commit 4d0541a

Please sign in to comment.