Sha256: c0ed06441744bba6a91ed7ef85ab987bb88d754c8fcf9ad7859eaa122ef68fef

Contents?: true

Size: 736 Bytes

Versions: 5

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

require 'bolt/error'

#
# Makes a query to puppetdb using the bolts puppetdb client.
#
Puppet::Functions.create_function(:puppetdb_query) do
  # This type could be more specific ASTQuery = Array[Variant[String, ASTQuery]]
  dispatch :make_query do
    param 'Variant[String, Array[Data]]', :query
    return_type 'Array[Data]'
  end

  def make_query(query)
    puppetdb_client = Puppet.lookup(:bolt_pdb_client) { nil }
    unless Puppet[:tasks] && puppetdb_client && Puppet.features.bolt?
      raise Puppet::ParseErrorWithIssue.from_issue_and_stack(
        Puppet::Pops::Issues::TASK_MISSING_BOLT, action: _('query facts from puppetdb')
      )
    end

    puppetdb_client.make_query(query)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bolt-0.20.6 bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
bolt-0.20.5 bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
bolt-0.20.3 bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
bolt-0.20.2 bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb
bolt-0.20.0 bolt-modules/boltlib/lib/puppet/functions/puppetdb_query.rb