Sha256: ba377831c95e0fdd4c1f99327b0d1e92811114452536ae5a792eb3f032b89f96

Contents?: true

Size: 1.85 KB

Versions: 31

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

require_relative 'path'
require_relative 'digest'

module Datadog
  module Core
    module Remote
      class Configuration
        # TargetMap stores information regarding Configuration::Path and Configuration::Target
        class TargetMap < Hash
          class << self
            def parse(hash)
              opaque_backend_state = hash['signed']['custom']['opaque_backend_state']
              version = hash['signed']['version']

              map = new

              map.instance_eval do
                @opaque_backend_state = opaque_backend_state
                @version = version
              end

              hash['signed']['targets'].each_with_object(map) do |(p, t), m|
                path = Configuration::Path.parse(p)
                target = Configuration::Target.parse(t)

                m[path] = target
              end
            end
          end

          attr_reader :opaque_backend_state, :version

          def initialize
            super

            @opaque_backend_state = nil
            @version = nil
          end

          private_class_method :new
        end

        # Target stores digest information
        class Target
          class << self
            def parse(hash)
              length = Integer(hash['length'])
              digests = Configuration::DigestList.parse(hash['hashes'])
              version = Integer(hash['custom']['v'])

              new(digests: digests, length: length, version: version)
            end
          end

          attr_reader :length, :digests, :version

          def initialize(digests:, length:, version:)
            @digests = digests
            @length = length
            @version = version
          end

          private_class_method :new

          def check(content)
            digests.check(content)
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
datadog-2.7.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.6.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.5.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.4.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.3.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.2.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.23.3 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.23.2 lib/datadog/core/remote/configuration/target.rb
datadog-2.1.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.0.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.23.1 lib/datadog/core/remote/configuration/target.rb
datadog-2.0.0.beta2 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.22.0 lib/datadog/core/remote/configuration/target.rb
datadog-2.0.0.beta1 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.21.1 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.21.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.20.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.19.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.18.0 lib/datadog/core/remote/configuration/target.rb
ddtrace-1.17.0 lib/datadog/core/remote/configuration/target.rb