Sha256: 0491776bec167facbe8afa57c7f95f6868072074d9566ec3cf4f6caee5665ba5

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'bolt/error'

# Evaulates all _plugin references in a hash and returns the resolved reference data.
Puppet::Functions.create_function(:resolve_references) do
  # Resolve references.
  # @param references A hash of reference data to resolve.
  # @return A hash of resolved reference data.
  # @example Resolve a hash of reference data
  #   $references = {
  #     "targets" => [
  #       "_plugin" => "terraform",
  #       "dir" => "path/to/terraform/project",
  #       "resource_type" => "aws_instance.web",
  #       "uri" => "public_ip"
  #     ]
  #   }
  #
  #   resolve_references($references)
  dispatch :resolve_references do
    param 'Data', :references
    return_type 'Data'
  end

  def resolve_references(references)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(
          Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
          action: 'resolve_references'
        )
    end

    executor = Puppet.lookup(:bolt_executor)
    executor.report_function_call(self.class.name)

    plugins = Puppet.lookup(:bolt_inventory).plugins
    plugins.resolve_references(references)
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bolt-1.49.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.48.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.47.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.45.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.44.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.43.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.42.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.41.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.40.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb
bolt-1.39.0 bolt-modules/boltlib/lib/puppet/functions/resolve_references.rb