Skip to content

Commit

Permalink
Merge pull request #2775 from cthorn42/maint/main/FACT-3484_add_libvi…
Browse files Browse the repository at this point in the history
…rt-lxc_container_detection

(FACT-3484) Add lxc-libvirt to container resolver detection
  • Loading branch information
mhashizume authored Nov 1, 2024
2 parents aae3671 + 6bace22 commit 76d7a61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/facter/resolvers/containers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def read_environ(fact_name)
case container
when 'lxc'
vm = 'lxc'
when 'lxc-virtwhat'
vm = 'lxc-virtwhat'
when 'podman'
vm = 'podman'
when 'crio'
Expand Down
14 changes: 14 additions & 0 deletions spec/facter/resolvers/containers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@
end
end

context 'when hypervisor is lxc-virtwhat and it is discovered by environ' do
let(:cgroup_output) { load_fixture('cgroup_file').read }
let(:environ_output) { ['container=lxc-virtwhat'] }
let(:result) { { 'lxc-virtwhat': {} } }

it 'return lxc-virtwhat for vm' do
expect(containers_resolver.resolve(:vm)).to eq('lxc-virtwhat')
end

it 'return lxc-virtwhat info for hypervisor' do
expect(containers_resolver.resolve(:hypervisor)).to eq(result)
end
end

context 'when hypervisor is neighter lxc nor docker' do
let(:cgroup_output) { load_fixture('cgroup_file').read }
let(:environ_output) { ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin'] }
Expand Down

0 comments on commit 76d7a61

Please sign in to comment.