Sha256: 6ed4b5f5c9eca2a122fde0d2a0e5a6b98570f02a7142e2e211f2adc0ab8afcce

Contents?: true

Size: 780 Bytes

Versions: 13

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module Facts
  module Linux
    class Partitions
      FACT_NAME = 'partitions'

      def call_the_resolver
        Facter::ResolvedFact.new(FACT_NAME, partitions)
      end

      def partitions
        parts = Facter::Resolvers::Partitions.resolve(:partitions)
        # We should exit early if we are running on a node with no partitions
        # (e.g. a diskless, netbooted VM)
        return nil unless parts

        mountpoints = Facter::Resolvers::Mountpoints.resolve(:mountpoints)
        return parts unless mountpoints

        mountpoints.reverse_each do |mnt|
          next unless parts[mnt[:device]]

          parts[mnt[:device]].merge!(mount: mnt[:path])
        end
        parts.empty? ? nil : parts
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
facter-4.10.0 lib/facter/facts/linux/partitions.rb
facter-4.9.0 lib/facter/facts/linux/partitions.rb
facter-4.8.0 lib/facter/facts/linux/partitions.rb
facter-4.7.1 lib/facter/facts/linux/partitions.rb
facter-4.7.0 lib/facter/facts/linux/partitions.rb
facter-4.6.1 lib/facter/facts/linux/partitions.rb
facter-4.6.0 lib/facter/facts/linux/partitions.rb
facter-4.5.2 lib/facter/facts/linux/partitions.rb
facter-4.5.1 lib/facter/facts/linux/partitions.rb
facter-4.5.0 lib/facter/facts/linux/partitions.rb
facter-4.4.3 lib/facter/facts/linux/partitions.rb
facter-4.4.2 lib/facter/facts/linux/partitions.rb
facter-4.4.1 lib/facter/facts/linux/partitions.rb