crossplane-contrib / crossplane-contrib/provider-sql
Proposal: Generic Query resource for arbitrary resource management
- Dominant language
- Go
- Stars
- 154
- Forks
- 119
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 8
Description
### What problem are you facing?
provider-sql currently supports 6 PostgreSQL object types: Database, Role, Grant, Extension, Schema, and DefaultPrivileges. However, PostgreSQL has hundreds of DDL/DCL object types. Users needing to manage tables, views, custom types, RLS policies, sequences, functions, triggers, publications, foreign tables, or any other object have no declarative path.
Related: #72 (Schema functions/custom SQL), #217 (Extend Grant kind)
### How could Crossplane help solve your problem?
We should consider creating a generic Query resource that lets users supply the SQL for each Crossplane lifecycle operation. An example design could have properties like:
observeQuery — SQL that returns rows if the resource exists (zero rows = doesn't exist)
createQueries — SQL statements executed in a transaction on create
updateQueries — SQL statements executed in a transaction when drift detected
deleteQueries — SQL statements executed in a transaction on CR deletion
Drift detection is handled by optional expectRows in the observe query: the user declares what the observe output should look like when the resource is up-to-date.
This should not prevent us from creating new resources when there is significant demand, but it should provide users an escape hatch when they need something we don't currently offer or we don't see enough demand to add. It will reduce pressure for new features for this project and ensure users can solve new use cases, even ones we have not planned or know about.
### Downsides
* It will be harder to justify creating new resources.
* It will be difficult to write good drift detection queries and drift handling
* No schema validation for queries
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.