Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DavidS opened this issue Oct 28, 2019 · 4 comments
Open

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

DavidS opened this issue Oct 28, 2019 · 4 comments
Labels
enhancement research A research or design task

Comments

@DavidS
Copy link
Contributor

DavidS commented Oct 28, 2019

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:

@DavidS DavidS changed the title Research - find a way to pass information from the manifest to the get method. Find a way to pass information from the manifest to the get method. Nov 6, 2019
@DavidS DavidS added research A research or design task enhancement labels Nov 6, 2019
@chadh
Copy link

chadh commented Jun 17, 2020

I don't need full manifest information, but I would love the get() method for a resource to be able to get the full context on all of that type of resource specified in the manifest. With simple_get_filter I can get a list of resource names, but not the arguments.

My use case is the puppetlabs-git git_config provider. The get() method would ostensibly be able to enumerate all git configs on a system, but the provider supports setting git configs per user. So enumerating all configs means iterating over all users, which in some environments is not an option. If the set of resources from the catalog was available, I could at least enumerate the current status of those. I realize this means that we can't ensure absent in an idempotent manner. It would also allow me to match the functionality of the low-level provider (which specifies value(), value=(), and mk_resource_methods()).

@chadh
Copy link

chadh commented Jun 17, 2020

my use case above does not apply here after all. I misunderstood that name and names parameters are actually hashes with all namevars, which is sufficient for my case.

@DavidS
Copy link
Contributor Author

DavidS commented Mar 30, 2021

Edited the description with a possible implementation path.

@kreeuwijk
Copy link

Implemented in #284

michaeltlombardi added a commit that referenced this issue May 17, 2021
This commit updates the BaseContext class initialization method
to take a second argument, catalog (default to nil), which
ensures that the @catalog instance variable is populated with
the value passed.

It also updates the context method in resource_api to pass the
catalog to that initializer if specified, or pass nil if not.

This does not add unit or acceptance tests for the behavior.
michaeltlombardi added a commit that referenced this issue May 17, 2021
This commit updates the BaseContext class initialization method
to take a second argument, catalog (default to nil), which
ensures that the @catalog instance variable is populated with
the value passed.

It also updates the context method in resource_api to pass the
catalog to that initializer if specified, or pass nil if not.

This does not add unit or acceptance tests for the behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement research A research or design task
Projects
None yet
Development

No branches or pull requests

3 participants