MMCT TEAM
Server IP : 111.118.215.189  /  Your IP : 18.216.95.250
Web Server : Apache
System : Linux md-in-83.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : a1673wkz ( 2475)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /usr/share/ruby/vendor_ruby/puppet/module_tool/applications/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : //usr/share/ruby/vendor_ruby/puppet/module_tool/applications/checksummer.rb
require 'json'
require 'puppet/module_tool/checksums'

module Puppet::ModuleTool
  module Applications
    class Checksummer < Application

      def initialize(path, options = {})
        @path = Pathname.new(path)
        super(options)
      end

      def run
        changes = []
        sums = Puppet::ModuleTool::Checksums.new(@path)
        checksums.each do |child_path, canonical_checksum|

          # Avoid checksumming the checksums.json file
          next if File.basename(child_path) == "checksums.json"

          path = @path + child_path
          unless path.exist? && canonical_checksum == sums.checksum(path)
            changes << child_path
          end
        end

        # Return an Array of strings representing file paths of files that have
        # been modified since this module was installed. All paths are relative
        # to the installed module directory. This return value is used by the
        # module_tool face changes action, and displayed on the console.
        #
        # Example return value:
        #
        #   [ "REVISION", "manifests/init.pp"]
        #
        changes
      end

      private

      def checksums
        if checksums_file.exist?
          JSON.parse(checksums_file.read)
        elsif metadata_file.exist?
          # Check metadata.json too; legacy modules store their checksums there.
          JSON.parse(metadata_file.read)['checksums'] or
          raise ArgumentError, "No file containing checksums found."
        else
          raise ArgumentError, "No file containing checksums found."
        end
      end

      def metadata_file
        @path + 'metadata.json'
      end

      def checksums_file
        @path + 'checksums.json'
      end
    end
  end
end

MMCT - 2023