Sha256: f9e69ee080199294f0f6ef0e7dbae5e8caada62a81f38f0588e2a9a4439e17ad

Contents?: true

Size: 1.35 KB

Versions: 13

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Facter
  module Resolvers
    class SolarisRelease < BaseResolver
      @semaphore = Mutex.new
      @fact_list ||= {}
      @os_version_regex_patterns = ['Solaris \d+ \d+/\d+ s(\d+)[sx]?_u(\d+)wos_',
                                    'Solaris (\d+)[.](\d+)', 'Solaris (\d+)']
      class << self
        private

        def post_resolve(fact_name)
          @fact_list.fetch(fact_name) { build_release_facts(fact_name) }
        end

        def build_release_facts(fact_name)
          result = Util::FileHelper.safe_read('/etc/release', nil)
          return @fact_list[fact_name] = nil if result.nil?

          @os_version_regex_patterns.each do |os_version_regex|
            major, minor = search_for_os_version(/#{os_version_regex}/, result)
            next unless major || minor

            @fact_list[:major] = major
            @fact_list[:minor] = minor
            @fact_list[:full] = major == '10' ? major + '_u' + minor : major + '.' + minor
            break
          end
          @fact_list[fact_name]
        end

        def search_for_os_version(regex_pattern, text)
          result = text.match(regex_pattern)
          major, minor = result.captures if result
          minor = regex_pattern == /Solaris (\d+)/ ? '0' : minor
          return [major, minor] if major && minor
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
facter-4.0.34 lib/facter/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.33 lib/facter/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.32 lib/facter/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.31 lib/facter/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.30 lib/facter/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.29 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.28 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.26 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.25 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.24 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.23 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.22 lib/resolvers/solaris/solaris_os_release_resolver.rb
facter-4.0.21 lib/resolvers/solaris/solaris_os_release_resolver.rb