Class: Datadog::Core::Remote::Configuration::TargetMap

Inherits:
Hash
  • Object
show all
Defined in:
lib/datadog/core/remote/configuration/target.rb

Overview

TargetMap stores information regarding Configuration::Path and Configuration::Target

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTargetMap

Returns a new instance of TargetMap.



42
43
44
45
46
47
# File 'lib/datadog/core/remote/configuration/target.rb', line 42

def initialize
  super

  @opaque_backend_state = nil
  @version = nil
end

Instance Attribute Details

#opaque_backend_stateObject (readonly)

Returns the value of attribute opaque_backend_state.



40
41
42
# File 'lib/datadog/core/remote/configuration/target.rb', line 40

def opaque_backend_state
  @opaque_backend_state
end

#versionObject (readonly)

Returns the value of attribute version.



40
41
42
# File 'lib/datadog/core/remote/configuration/target.rb', line 40

def version
  @version
end

Class Method Details

.parse(hash) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/datadog/core/remote/configuration/target.rb', line 13

def parse(hash)
  signed = hash.fetch('signed')
  # Note that the +dig+ call permits +hash['signed']+ to be
  # missing the +custom+ subtree entirely.
  # Previously the subtree was required but +opaque_backend_state+
  # could still be missing (and obtained here as nil).
  opaque_backend_state = signed.dig('custom', 'opaque_backend_state')
  # The version appears to be optional to the rest of this class,
  # and we have tests that do not provide it.
  version = signed['version']

  map = new

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

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

    m[path] = target
  end
end