diff --git a/lib/facter/facts/aix/filesystems.rb b/lib/facter/facts/aix/filesystems.rb index d8ae3659e2..9e80ac8be5 100644 --- a/lib/facter/facts/aix/filesystems.rb +++ b/lib/facter/facts/aix/filesystems.rb @@ -6,7 +6,7 @@ class Filesystems FACT_NAME = 'filesystems' def call_the_resolver - fact_value = Facter::Resolvers::Aix::Filesystem.resolve(:file_systems) + fact_value = Facter::Resolvers::Aix::Filesystems.resolve(:file_systems) Facter::ResolvedFact.new(FACT_NAME, fact_value) end end diff --git a/lib/facter/facts/linux/hypervisors/docker.rb b/lib/facter/facts/linux/hypervisors/docker.rb index cd309d16fa..ed440f9c7a 100644 --- a/lib/facter/facts/linux/hypervisors/docker.rb +++ b/lib/facter/facts/linux/hypervisors/docker.rb @@ -12,7 +12,7 @@ def call_the_resolver end def check_docker - info = Facter::Resolvers::Containers.resolve(:hypervisor) + info = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) info[:docker] if info end end diff --git a/lib/facter/facts/linux/hypervisors/lxc.rb b/lib/facter/facts/linux/hypervisors/lxc.rb index 842da6d4f9..0f6894332d 100644 --- a/lib/facter/facts/linux/hypervisors/lxc.rb +++ b/lib/facter/facts/linux/hypervisors/lxc.rb @@ -12,7 +12,7 @@ def call_the_resolver end def check_lxc - info = Facter::Resolvers::Containers.resolve(:hypervisor) + info = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) info[:lxc] if info end end diff --git a/lib/facter/facts/linux/hypervisors/systemd_nspawn.rb b/lib/facter/facts/linux/hypervisors/systemd_nspawn.rb index ef7b2326cc..4996baa80f 100644 --- a/lib/facter/facts/linux/hypervisors/systemd_nspawn.rb +++ b/lib/facter/facts/linux/hypervisors/systemd_nspawn.rb @@ -12,7 +12,7 @@ def call_the_resolver end def check_nspawn - info = Facter::Resolvers::Containers.resolve(:hypervisor) + info = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) info[:systemd_nspawn] if info end end diff --git a/lib/facter/facts/linux/system_uptime/days.rb b/lib/facter/facts/linux/system_uptime/days.rb index a8df17a004..fdcf30d516 100644 --- a/lib/facter/facts/linux/system_uptime/days.rb +++ b/lib/facter/facts/linux/system_uptime/days.rb @@ -8,7 +8,7 @@ class Days ALIASES = 'uptime_days' def call_the_resolver - hypervisors = Facter::Resolvers::Containers.resolve(:hypervisor) + hypervisors = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) fact_value = if hypervisors && hypervisors[:docker] Facter::Resolvers::Linux::DockerUptime.resolve(:days) diff --git a/lib/facter/facts/linux/system_uptime/hours.rb b/lib/facter/facts/linux/system_uptime/hours.rb index e021bfbd8c..e7c6d7e87d 100644 --- a/lib/facter/facts/linux/system_uptime/hours.rb +++ b/lib/facter/facts/linux/system_uptime/hours.rb @@ -8,7 +8,7 @@ class Hours ALIASES = 'uptime_hours' def call_the_resolver - hypervisors = Facter::Resolvers::Containers.resolve(:hypervisor) + hypervisors = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) fact_value = if hypervisors && hypervisors[:docker] Facter::Resolvers::Linux::DockerUptime.resolve(:hours) diff --git a/lib/facter/facts/linux/system_uptime/seconds.rb b/lib/facter/facts/linux/system_uptime/seconds.rb index 981c0d1e38..4968789b30 100644 --- a/lib/facter/facts/linux/system_uptime/seconds.rb +++ b/lib/facter/facts/linux/system_uptime/seconds.rb @@ -8,7 +8,7 @@ class Seconds ALIASES = 'uptime_seconds' def call_the_resolver - hypervisors = Facter::Resolvers::Containers.resolve(:hypervisor) + hypervisors = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) fact_value = if hypervisors && hypervisors[:docker] Facter::Resolvers::Linux::DockerUptime.resolve(:seconds) diff --git a/lib/facter/facts/linux/system_uptime/uptime.rb b/lib/facter/facts/linux/system_uptime/uptime.rb index 3ab4e4108b..6dc9729c74 100644 --- a/lib/facter/facts/linux/system_uptime/uptime.rb +++ b/lib/facter/facts/linux/system_uptime/uptime.rb @@ -8,7 +8,7 @@ class Uptime ALIASES = 'uptime' def call_the_resolver - hypervisors = Facter::Resolvers::Containers.resolve(:hypervisor) + hypervisors = Facter::Resolvers::Linux::Containers.resolve(:hypervisor) fact_value = if hypervisors && hypervisors[:docker] Facter::Resolvers::Linux::DockerUptime.resolve(:uptime) diff --git a/lib/facter/framework/core/file_loader.rb b/lib/facter/framework/core/file_loader.rb index c89aadd955..00bb66f195 100644 --- a/lib/facter/framework/core/file_loader.rb +++ b/lib/facter/framework/core/file_loader.rb @@ -52,16 +52,11 @@ require_relative '../../resolvers/augeas' require_relative '../../resolvers/az' require_relative '../../resolvers/base_resolver' -require_relative '../../resolvers/containers' require_relative '../../resolvers/debian_version' -require_relative '../../resolvers/disks' -require_relative '../../resolvers/dmi' require_relative '../../resolvers/dmi_decode' require_relative '../../resolvers/ec2' require_relative '../../resolvers/eos_release' require_relative '../../resolvers/facterversion' -require_relative '../../resolvers/filesystems' -require_relative '../../resolvers/fips_enabled' require_relative '../../resolvers/gce' require_relative '../../resolvers/hostname' require_relative '../../resolvers/identity' @@ -69,15 +64,12 @@ require_relative '../../resolvers/lpar' require_relative '../../resolvers/lsb_release' require_relative '../../resolvers/lspci' -require_relative '../../resolvers/memory' require_relative '../../resolvers/mountpoints' require_relative '../../resolvers/networking' require_relative '../../resolvers/open_vz' require_relative '../../resolvers/os_release' require_relative '../../resolvers/partitions' require_relative '../../resolvers/path' -require_relative '../../resolvers/processors' -require_relative '../../resolvers/processors_lscpu' require_relative '../../resolvers/redhat_release' require_relative '../../resolvers/release_from_first_line' require_relative '../../resolvers/ruby' @@ -219,7 +211,7 @@ require_relative '../../resolvers/aix/architecture' require_relative '../../resolvers/aix/disks' - require_relative '../../resolvers/aix/filesystem' + require_relative '../../resolvers/aix/filesystems' require_relative '../../resolvers/aix/hardware' require_relative '../../resolvers/aix/load_averages' require_relative '../../resolvers/aix/memory' @@ -510,10 +502,18 @@ require_relative '../../facts/linux/virtual' require_relative '../../facts/linux/xen' + require_relative '../../resolvers/linux/containers' + require_relative '../../resolvers/linux/disks' + require_relative '../../resolvers/linux/dmi' require_relative '../../resolvers/linux/docker_uptime' + require_relative '../../resolvers/linux/filesystems' + require_relative '../../resolvers/linux/fips_enabled' require_relative '../../resolvers/linux/hostname' require_relative '../../resolvers/linux/load_averages' + require_relative '../../resolvers/linux/memory' require_relative '../../resolvers/linux/networking' + require_relative '../../resolvers/linux/processors' + require_relative '../../resolvers/linux/processors_lscpu' when 'linuxmint' require_relative '../../facts/linuxmint/os/name' diff --git a/lib/facter/resolvers/aix/filesystem.rb b/lib/facter/resolvers/aix/filesystems.rb similarity index 95% rename from lib/facter/resolvers/aix/filesystem.rb rename to lib/facter/resolvers/aix/filesystems.rb index 56186a2dc6..dcc7770765 100644 --- a/lib/facter/resolvers/aix/filesystem.rb +++ b/lib/facter/resolvers/aix/filesystems.rb @@ -3,7 +3,7 @@ module Facter module Resolvers module Aix - class Filesystem < BaseResolver + class Filesystems < BaseResolver init_resolver class << self diff --git a/lib/facter/resolvers/containers.rb b/lib/facter/resolvers/containers.rb deleted file mode 100644 index 912a433fb3..0000000000 --- a/lib/facter/resolvers/containers.rb +++ /dev/null @@ -1,79 +0,0 @@ -# frozen_string_literal: true - -module Facter - module Resolvers - class Containers < BaseResolver - # :virtual - # :hypervisor - - init_resolver - - INFO = { 'docker' => 'id', 'lxc' => 'name' }.freeze - - class << self - private - - def post_resolve(fact_name, _options) - @fact_list.fetch(fact_name) do - read_environ(fact_name) || read_cgroup(fact_name) - end - end - - def read_cgroup(fact_name) - output_cgroup = Facter::Util::FileHelper.safe_read('/proc/1/cgroup', nil) - return unless output_cgroup - - output_docker = %r{docker/(.+)}.match(output_cgroup) - output_lxc = %r{^/lxc/([^/]+)}.match(output_cgroup) - - info, vm = extract_vm_and_info(output_docker, output_lxc) - @fact_list[:vm] = vm - @fact_list[:hypervisor] = { vm.to_sym => info } if vm - @fact_list[fact_name] - end - - def read_environ(fact_name) - begin - container = Facter::Util::Linux::Proc.getenv_for_pid(1, 'container') - rescue StandardError => e - log.warn("Unable to getenv for pid 1, '#{e}'") - return nil - end - return if container.nil? || container.empty? - - info = {} - case container - when 'lxc' - vm = 'lxc' - when 'podman' - vm = 'podman' - when 'crio' - vm = 'crio' - when 'systemd-nspawn' - vm = 'systemd_nspawn' - info = { 'id' => Facter::Util::FileHelper.safe_read('/etc/machine-id', nil).strip } - else - vm = 'container_other' - log.warn("Container runtime, '#{container}', is unsupported, setting to '#{vm}'") - end - @fact_list[:vm] = vm - @fact_list[:hypervisor] = { vm.to_sym => info } if vm - @fact_list[fact_name] - end - - def extract_vm_and_info(output_docker, output_lxc) - vm = nil - if output_docker - vm = 'docker' - info = output_docker[1] - elsif output_lxc - vm = 'lxc' - info = output_lxc[1] - end - - [info ? { INFO[vm] => info } : {}, vm] - end - end - end - end -end diff --git a/lib/facter/resolvers/linux/containers.rb b/lib/facter/resolvers/linux/containers.rb new file mode 100644 index 0000000000..1382815b9b --- /dev/null +++ b/lib/facter/resolvers/linux/containers.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true + +module Facter + module Resolvers + module Linux + class Containers < BaseResolver + # :virtual + # :hypervisor + + init_resolver + + INFO = { 'docker' => 'id', 'lxc' => 'name' }.freeze + + class << self + private + + def post_resolve(fact_name, _options) + @fact_list.fetch(fact_name) do + read_environ(fact_name) || read_cgroup(fact_name) + end + end + + def read_cgroup(fact_name) + output_cgroup = Facter::Util::FileHelper.safe_read('/proc/1/cgroup', nil) + return unless output_cgroup + + output_docker = %r{docker/(.+)}.match(output_cgroup) + output_lxc = %r{^/lxc/([^/]+)}.match(output_cgroup) + + info, vm = extract_vm_and_info(output_docker, output_lxc) + @fact_list[:vm] = vm + @fact_list[:hypervisor] = { vm.to_sym => info } if vm + @fact_list[fact_name] + end + + def read_environ(fact_name) + begin + container = Facter::Util::Linux::Proc.getenv_for_pid(1, 'container') + rescue StandardError => e + log.warn("Unable to getenv for pid 1, '#{e}'") + return nil + end + return if container.nil? || container.empty? + + info = {} + case container + when 'lxc' + vm = 'lxc' + when 'podman' + vm = 'podman' + when 'crio' + vm = 'crio' + when 'systemd-nspawn' + vm = 'systemd_nspawn' + info = { 'id' => Facter::Util::FileHelper.safe_read('/etc/machine-id', nil).strip } + else + vm = 'container_other' + log.warn("Container runtime, '#{container}', is unsupported, setting to '#{vm}'") + end + @fact_list[:vm] = vm + @fact_list[:hypervisor] = { vm.to_sym => info } if vm + @fact_list[fact_name] + end + + def extract_vm_and_info(output_docker, output_lxc) + vm = nil + if output_docker + vm = 'docker' + info = output_docker[1] + elsif output_lxc + vm = 'lxc' + info = output_lxc[1] + end + + [info ? { INFO[vm] => info } : {}, vm] + end + end + end + end + end +end diff --git a/lib/facter/resolvers/disks.rb b/lib/facter/resolvers/linux/disks.rb similarity index 100% rename from lib/facter/resolvers/disks.rb rename to lib/facter/resolvers/linux/disks.rb diff --git a/lib/facter/resolvers/dmi.rb b/lib/facter/resolvers/linux/dmi.rb similarity index 100% rename from lib/facter/resolvers/dmi.rb rename to lib/facter/resolvers/linux/dmi.rb diff --git a/lib/facter/resolvers/filesystems.rb b/lib/facter/resolvers/linux/filesystems.rb similarity index 100% rename from lib/facter/resolvers/filesystems.rb rename to lib/facter/resolvers/linux/filesystems.rb diff --git a/lib/facter/resolvers/fips_enabled.rb b/lib/facter/resolvers/linux/fips_enabled.rb similarity index 100% rename from lib/facter/resolvers/fips_enabled.rb rename to lib/facter/resolvers/linux/fips_enabled.rb diff --git a/lib/facter/resolvers/memory.rb b/lib/facter/resolvers/linux/memory.rb similarity index 100% rename from lib/facter/resolvers/memory.rb rename to lib/facter/resolvers/linux/memory.rb diff --git a/lib/facter/resolvers/processors.rb b/lib/facter/resolvers/linux/processors.rb similarity index 100% rename from lib/facter/resolvers/processors.rb rename to lib/facter/resolvers/linux/processors.rb diff --git a/lib/facter/resolvers/processors_lscpu.rb b/lib/facter/resolvers/linux/processors_lscpu.rb similarity index 100% rename from lib/facter/resolvers/processors_lscpu.rb rename to lib/facter/resolvers/linux/processors_lscpu.rb diff --git a/lib/facter/util/facts/posix/virtual_detector.rb b/lib/facter/util/facts/posix/virtual_detector.rb index cc4ba11b70..2ffd4c8391 100644 --- a/lib/facter/util/facts/posix/virtual_detector.rb +++ b/lib/facter/util/facts/posix/virtual_detector.rb @@ -16,7 +16,7 @@ def platform private def check_docker_lxc - Facter::Resolvers::Containers.resolve(:vm) + Facter::Resolvers::Linux::Containers.resolve(:vm) end def check_gce diff --git a/spec/facter/facts/aix/filesystems_spec.rb b/spec/facter/facts/aix/filesystems_spec.rb index f7d66d16dc..6b9c03e6b2 100644 --- a/spec/facter/facts/aix/filesystems_spec.rb +++ b/spec/facter/facts/aix/filesystems_spec.rb @@ -7,7 +7,7 @@ let(:files) { 'apfs,autofs,devfs' } before do - allow(Facter::Resolvers::Aix::Filesystem).to \ + allow(Facter::Resolvers::Aix::Filesystems).to \ receive(:resolve).with(:file_systems).and_return(files) end diff --git a/spec/facter/facts/linux/hypervisors/docker_spec.rb b/spec/facter/facts/linux/hypervisors/docker_spec.rb index 471bcefe3c..3484e41629 100644 --- a/spec/facter/facts/linux/hypervisors/docker_spec.rb +++ b/spec/facter/facts/linux/hypervisors/docker_spec.rb @@ -5,7 +5,7 @@ subject(:fact) { Facts::Linux::Hypervisors::Docker.new } before do - allow(Facter::Resolvers::Containers).to \ + allow(Facter::Resolvers::Linux::Containers).to \ receive(:resolve).with(:hypervisor).and_return(hv) end diff --git a/spec/facter/facts/linux/hypervisors/lxc_spec.rb b/spec/facter/facts/linux/hypervisors/lxc_spec.rb index 5755723412..877f5e1b0c 100644 --- a/spec/facter/facts/linux/hypervisors/lxc_spec.rb +++ b/spec/facter/facts/linux/hypervisors/lxc_spec.rb @@ -5,7 +5,7 @@ subject(:fact) { Facts::Linux::Hypervisors::Lxc.new } before do - allow(Facter::Resolvers::Containers).to \ + allow(Facter::Resolvers::Linux::Containers).to \ receive(:resolve).with(:hypervisor).and_return(hv) end diff --git a/spec/facter/facts/linux/hypervisors/systemd_nspawn_spec.rb b/spec/facter/facts/linux/hypervisors/systemd_nspawn_spec.rb index 6ca61fbc82..41f475924a 100644 --- a/spec/facter/facts/linux/hypervisors/systemd_nspawn_spec.rb +++ b/spec/facter/facts/linux/hypervisors/systemd_nspawn_spec.rb @@ -5,7 +5,7 @@ subject(:fact) { Facts::Linux::Hypervisors::SystemdNspawn.new } before do - allow(Facter::Resolvers::Containers).to \ + allow(Facter::Resolvers::Linux::Containers).to \ receive(:resolve).with(:hypervisor).and_return(hv) end diff --git a/spec/facter/facts/linux/system_uptime/days_spec.rb b/spec/facter/facts/linux/system_uptime/days_spec.rb index 562c1d534a..a82ca71ac7 100644 --- a/spec/facter/facts/linux/system_uptime/days_spec.rb +++ b/spec/facter/facts/linux/system_uptime/days_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:days).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:days).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/hours_spec.rb b/spec/facter/facts/linux/system_uptime/hours_spec.rb index 70da047d2b..3db68813b2 100644 --- a/spec/facter/facts/linux/system_uptime/hours_spec.rb +++ b/spec/facter/facts/linux/system_uptime/hours_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:hours).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:hours).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/seconds_spec.rb b/spec/facter/facts/linux/system_uptime/seconds_spec.rb index b8b05932ba..ecb18624a9 100644 --- a/spec/facter/facts/linux/system_uptime/seconds_spec.rb +++ b/spec/facter/facts/linux/system_uptime/seconds_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:seconds).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:seconds).and_return(value) end diff --git a/spec/facter/facts/linux/system_uptime/uptime_spec.rb b/spec/facter/facts/linux/system_uptime/uptime_spec.rb index afe720e3ba..363954a4d2 100644 --- a/spec/facter/facts/linux/system_uptime/uptime_spec.rb +++ b/spec/facter/facts/linux/system_uptime/uptime_spec.rb @@ -8,7 +8,7 @@ context 'when on linux' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return(nil) allow(Facter::Resolvers::Uptime).to receive(:resolve).with(:uptime).and_return(value) end @@ -21,7 +21,7 @@ context 'when in docker container' do before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:hypervisor).and_return({ docker: '123' }) allow(Facter::Resolvers::Linux::DockerUptime).to receive(:resolve).with(:uptime).and_return(value) end diff --git a/spec/facter/resolvers/aix/filesystem_spec.rb b/spec/facter/resolvers/aix/filesystems_spec.rb similarity index 72% rename from spec/facter/resolvers/aix/filesystem_spec.rb rename to spec/facter/resolvers/aix/filesystems_spec.rb index f231294d33..68de8c51fe 100644 --- a/spec/facter/resolvers/aix/filesystem_spec.rb +++ b/spec/facter/resolvers/aix/filesystems_spec.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -describe Facter::Resolvers::Aix::Filesystem do +describe Facter::Resolvers::Aix::Filesystems do let(:filesystems) { 'ahafs,cdrfs,namefs,procfs,sfs' } after do - Facter::Resolvers::Aix::Filesystem.invalidate_cache + Facter::Resolvers::Aix::Filesystems.invalidate_cache end context 'when vfs file is readable' do @@ -15,7 +15,7 @@ end it 'returns filesystems' do - result = Facter::Resolvers::Aix::Filesystem.resolve(:file_systems) + result = Facter::Resolvers::Aix::Filesystems.resolve(:file_systems) expect(result).to eq(filesystems) end @@ -29,7 +29,7 @@ end it 'returns nil' do - result = Facter::Resolvers::Aix::Filesystem.resolve(:file_systems) + result = Facter::Resolvers::Aix::Filesystems.resolve(:file_systems) expect(result).to be(nil) end diff --git a/spec/facter/resolvers/containers_spec.rb b/spec/facter/resolvers/linux/containers_spec.rb similarity index 96% rename from spec/facter/resolvers/containers_spec.rb rename to spec/facter/resolvers/linux/containers_spec.rb index f74d94f40a..4ded3440fc 100644 --- a/spec/facter/resolvers/containers_spec.rb +++ b/spec/facter/resolvers/linux/containers_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -describe Facter::Resolvers::Containers do - subject(:containers_resolver) { Facter::Resolvers::Containers } +describe Facter::Resolvers::Linux::Containers do + subject(:containers_resolver) { Facter::Resolvers::Linux::Containers } before do allow(Facter::Util::FileHelper).to receive(:safe_read) diff --git a/spec/facter/util/facts/posix/virtual_detector_spec.rb b/spec/facter/util/facts/posix/virtual_detector_spec.rb index 63f23911cf..46b26de206 100644 --- a/spec/facter/util/facts/posix/virtual_detector_spec.rb +++ b/spec/facter/util/facts/posix/virtual_detector_spec.rb @@ -12,12 +12,12 @@ let(:vm) { 'docker' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(vm) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(vm) end - it 'calls Facter::Resolvers::Containers' do + it 'calls Facter::Resolvers::Linux::Containers' do detector.platform - expect(Facter::Resolvers::Containers).to have_received(:resolve).with(:vm) + expect(Facter::Resolvers::Linux::Containers).to have_received(:resolve).with(:vm) end it 'returns container type' do @@ -29,7 +29,7 @@ let(:value) { 'jail' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return('jail') end @@ -48,7 +48,7 @@ let(:value) { 'vmm' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return('vmm') end @@ -68,7 +68,7 @@ let(:value) { 'gce' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return('Google Engine') @@ -89,7 +89,7 @@ let(:value) { 'xenhvm' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -112,7 +112,7 @@ let(:value) { 'vmware_fusion' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -136,7 +136,7 @@ let(:value) { 'openvzve' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -161,7 +161,7 @@ let(:value) { 'vserver_host' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -187,7 +187,7 @@ let(:value) { 'xen0' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -214,7 +214,7 @@ let(:value) { 'bochs' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return(nil) @@ -248,7 +248,7 @@ let(:value) { 'hyperv' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return(nil) @@ -277,7 +277,7 @@ let(:value) { 'illumos-lx' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Linux::DmiBios).to receive(:resolve).with(:bios_vendor).and_return(nil) @@ -295,7 +295,7 @@ let(:vm) { 'physical' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return(nil) @@ -318,7 +318,7 @@ let(:vm) { 'physical' } before do - allow(Facter::Resolvers::Containers).to receive(:resolve).with(:vm).and_return(nil) + allow(Facter::Resolvers::Linux::Containers).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Freebsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::Openbsd::Virtual).to receive(:resolve).with(:vm).and_return(nil) allow(Facter::Resolvers::VirtWhat).to receive(:resolve).with(:vm).and_return(nil)