puppetlabs / puppetlabs/puppet-resource_api
catalog access / catalog transformations
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 27
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
Use Case
- security assertions on the catalog
- global transmutations of the catalog
- generating component resources from native providers (e.g.
concat->file) - agent-side catalog operations (e.g. deferred functions)
Describe the Solution You Would Like
Add new compilation stages before the catalog is transmitted from the server and after it has been received at the agent. Allow modules to inject transformation functions that can mutate the catalog before further processing. Each of the transformation functions would take (part of) the catalog and be able to add/change/delete resources as it sees fit.
To help operators understand the impact of transformation functions, they should provide metadata of which types the function looks at and which types get emitted by them. This information can be used to ease implementation (only pass in requested resources, reducing filtering requirements) and safety (check that only expected types are returned) of those functions. At the same time this information can be used to ascertain a safe application order of the transforms:
- two or more transforms requesting different type inputs are always safe to run and do not require a specific order
- given
f(A): Bandg(C): D,fandghave no order requirement
- given
- two or more transforms requesting the same input types are always safe to run and do not require a specific order
- given
f(A): Bandg(A): C,fandghave no order requirement
- given
- a transform has to run after all other transforms that output required types for this transform
- given
f(A): Bandg(B): C,fneeds to be applied beforeg
- given
- a cycle in transform type requirements is illegal
- given
f(A): Bandg(B): A,fandgare incompatible - except for the special case of a single transform
f(A): A, which can be safely applied
- given
Should this turn out to be too restrictive for useful configurations, we can consider allowing folks to provide a partial priority override for transforms that conflict. Caveat emptor that in those cases the operator needs to take on additional responsibilities to understand and sequence those transforms and the consequences that'll have on the catalog.
Describe Alternatives You've Considered
Exposing the current mechanisms for doing these kinds of transformations would make implementing the Resource API outside of puppet a lot harder, while at the same time perpetuating the brittleness and opaqueness of the generate approach.
Additional Context
Originally tracked in https://tickets.puppetlabs.com/browse/PDK-533 , https://github.com/puppetlabs/puppet-specifications/blob/master/language/resource-api/README.md#catalog-access
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
Read the linked resource-api README and this issue first; no repository files or tests are identified. The design needs agreement on the transformation API, metadata, ordering, and cycle handling before implementation can be scoped. Done means the agreed catalog transformations work safely with coverage for their ordering rules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100