Class: BoltServer::Plugin::PuppetConnectData

Inherits:
Object
  • Object
show all
Defined in:
lib/bolt_server/plugin/puppet_connect_data.rb

Instance Method Summary collapse

Constructor Details

#initialize(data, **_opts) ⇒ PuppetConnectData

Returns a new instance of PuppetConnectData.



6
7
8
# File 'lib/bolt_server/plugin/puppet_connect_data.rb', line 6

def initialize(data, **_opts)
  @data = data
end

Instance Method Details

#hooksObject



14
15
16
# File 'lib/bolt_server/plugin/puppet_connect_data.rb', line 14

def hooks
  %i[resolve_reference validate_resolve_reference]
end

#nameObject



10
11
12
# File 'lib/bolt_server/plugin/puppet_connect_data.rb', line 10

def name
  'puppet_connect_data'
end

#resolve_reference(opts) ⇒ Object



18
19
20
21
22
# File 'lib/bolt_server/plugin/puppet_connect_data.rb', line 18

def resolve_reference(opts)
  key = opts['key']

  @data.dig(key, 'value')
end

#validate_resolve_reference(opts) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bolt_server/plugin/puppet_connect_data.rb', line 24

def validate_resolve_reference(opts)
  unless opts['key']
    raise Bolt::ValidationError,
          "puppet_connect_data plugin requires that 'key' be specified"
  end

  unless @data.key?(opts['key'])
    raise Bolt::ValidationError,
          "puppet_connect_data plugin tried to lookup key '#{opts['key']}' but no value was found"
  end
end