puppetlabs / puppetlabs/puppet-resource_api
Find a way to pass information from the manifest to the `get` method.
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 27
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
Example for how this is currently used/implemented:
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:
- Add a
raw_catalog_accessfeature flag to https://github.com/puppetlabs/puppet-resource_api/blob/bd93dbac616baa4ffa18c99a0b45946c9d474fec/lib/puppet/resource_api/type_definition.rb#L37 - add
catalogaccessor to https://github.com/puppetlabs/puppet-resource_api/blob/bd93dbac616baa4ffa18c99a0b45946c9d474fec/lib/puppet/resource_api/base_context.rb#L13 - pass reference to
resource.catalogto context every time one is created iff theraw_catalog_accessfeature is declared on the type definition- https://github.com/puppetlabs/puppet-resource_api/blob/bd93dbac616baa4ffa18c99a0b45946c9d474fec/lib/puppet/resource_api.rb#L428-L434 - might need additional changes if
resource.catalogis not available at the class level - add pass through here: https://github.com/puppetlabs/puppet-resource_api/blob/bd93dbac616baa4ffa18c99a0b45946c9d474fec/lib/puppet/resource_api/io_context.rb#L8
- https://github.com/puppetlabs/puppet-resource_api/blob/bd93dbac616baa4ffa18c99a0b45946c9d474fec/lib/puppet/resource_api.rb#L428-L434 - might need additional changes if
- adjust testing for these changes
- update docs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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