Sha256: 5bbdbdce176514aab667c14f648eac455d2d4d8eecd6b68f35452c6b921cd447

Contents?: true

Size: 1.79 KB

Versions: 120

Compression:

Stored size: 1.79 KB

Contents

require_relative '../../../puppet/util/json'
require_relative '../../../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?
          Puppet::Util::Json.load(checksums_file.read)
        elsif metadata_file.exist?
          # Check metadata.json too; legacy modules store their checksums there.
          Puppet::Util::Json.load(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

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
puppet-7.34.0 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.34.0-x86-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.34.0-x64-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.34.0-universal-darwin lib/puppet/module_tool/applications/checksummer.rb
puppet-7.33.0 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.33.0-x86-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.33.0-x64-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.33.0-universal-darwin lib/puppet/module_tool/applications/checksummer.rb
puppet-7.32.1 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.32.1-x86-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.32.1-x64-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.32.1-universal-darwin lib/puppet/module_tool/applications/checksummer.rb
puppet-7.31.0 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.31.0-x86-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.31.0-x64-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.31.0-universal-darwin lib/puppet/module_tool/applications/checksummer.rb
puppet-7.30.0 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.30.0-x86-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.30.0-x64-mingw32 lib/puppet/module_tool/applications/checksummer.rb
puppet-7.30.0-universal-darwin lib/puppet/module_tool/applications/checksummer.rb