puppetlabs / puppetlabs/puppet-resource_api

Find a way to pass information from the manifest to the `get` method.

Open
#242 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement research
Dominant language
Ruby
Stars
27
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Example for how this is currently used/implemented:

https://github.com/puppetlabs/puppetlabs-sqlserver/blob/b36eecf3fdadb3d45c9691fcac2e92c66fa3ad30/lib/puppet/provider/sqlserver_tsql/mssql.rb#L16-L26

  def get_config(instance = resource[:instance])
    config_resc = resource.catalog.resources.find do |resc|
      resc.title =~ %r{Sqlserver::Config} &&
        resc.original_parameters[:instance_name] =~ %r{#{instance}}i
    end
    if config_resc.nil?
      raise("Sqlserver_tsql[#{resource.title}] was unable to retrieve the config, please ensure the catalog contains sqlserver::config{'#{resource[:instance]}':}")
    end


    config_resc.original_parameters
  end

Puppet::Type's resource.catalog.resources provides access to other resources in the current catalog.

Possible implementation:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the proposed changes in lib/puppet/resource_api/type_definition.rb, base_context.rb, resource_api.rb, and io_context.rb. Trace how contexts are created and determine how catalog access should be passed when raw_catalog_access is declared. Update tests and documentation, and verify that get can access the current catalog without changing types that do not declare the feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.