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:
- Add a
raw_catalog_access feature flag to
|
supported_features = %w[supports_noop canonicalize remote_resource simple_get_filter].freeze |
- add
catalog accessor to
|
def initialize(definition) |
- pass reference to
resource.catalog to context every time one is created iff the raw_catalog_access feature is declared on the type definition
|
define_singleton_method(:context) do |
|
@context ||= PuppetContext.new(TypeDefinition.new(definition)) |
|
end |
|
|
|
def context |
|
self.class.context |
|
end |
- might need additional changes if resource.catalog is not available at the class level
- add pass through here:
|
def initialize(definition, target = $stderr, transport = nil) |
- adjust testing for these changes
- update docs
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
Puppet::Type'sresource.catalog.resourcesprovides access to other resources in the current catalog.Possible implementation:
raw_catalog_accessfeature flag topuppet-resource_api/lib/puppet/resource_api/type_definition.rb
Line 37 in bd93dba
catalogaccessor topuppet-resource_api/lib/puppet/resource_api/base_context.rb
Line 13 in bd93dba
resource.catalogto context every time one is created iff theraw_catalog_accessfeature is declared on the type definitionpuppet-resource_api/lib/puppet/resource_api.rb
Lines 428 to 434 in bd93dba
resource.catalogis not available at the class levelpuppet-resource_api/lib/puppet/resource_api/io_context.rb
Line 8 in bd93dba