feat: implement User resource for managing Kafka users#194
Open
zanozbot wants to merge 5 commits into
Open
Conversation
Signed-off-by: Žan Ožbot <zan.ozbot@gmail.com>
Signed-off-by: Žan Ožbot <zan.ozbot@gmail.com>
Signed-off-by: Žan Ožbot <zan.ozbot@gmail.com>
Signed-off-by: Žan Ožbot <zan.ozbot@gmail.com>
There was a problem hiding this comment.
Pull request overview
Implements a new Crossplane managed resource (User) to manage Kafka SCRAM users, including controllers and helper client logic for both cluster-scoped (user.kafka.crossplane.io/v1alpha1) and namespace-scoped (user.kafka.m.crossplane.io/v1alpha1) APIs.
Changes:
- Added
UserCRDs, API types, and scheme registration for cluster-scoped and namespaced variants. - Implemented new controllers (cluster + namespaced) that support Observe/Create/Update/Delete, password resolution (BYOP vs auto-generate), and connection Secret publishing.
- Added Kafka SCRAM helper client implementation and unit tests, plus docs/examples updates for the new resource.
Reviewed changes
Copilot reviewed 24 out of 30 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the User resource, connection Secret contents, and import workflow. |
| package/crds/user.kafka.m.crossplane.io_users.yaml | Adds namespaced User CRD. |
| package/crds/user.kafka.crossplane.io_users.yaml | Adds cluster-scoped User CRD. |
| internal/controller/namespaced/user/user.go | Namespaced User controller implementation. |
| internal/controller/namespaced/user/user_test.go | Unit tests for namespaced controller helpers (password resolution, etc.). |
| internal/controller/namespaced/kafka.go | Registers the namespaced User controller. |
| internal/controller/cluster/user/user.go | Cluster-scoped User controller implementation. |
| internal/controller/cluster/user/user_test.go | Unit tests for cluster-scoped controller helpers (password resolution, etc.). |
| internal/controller/cluster/kafka.go | Registers the cluster-scoped User controller. |
| internal/clients/kafka/user/user.go | Kafka SCRAM helper client (exists/observe/upsert/delete). |
| internal/clients/kafka/user/user_test.go | Unit tests for Kafka SCRAM helper client. |
| examples/namespaced/user/v1alpha1/user.yaml | Example manifest for namespaced User. |
| examples/namespaced/user/v1alpha1/user-with-password-secret.yaml | Example for namespaced import/BYOP password usage. |
| examples/cluster/user/v1alpha1/user.yaml | Example manifest for cluster-scoped User. |
| examples/cluster/user/v1alpha1/user-with-password-secret.yaml | Example for cluster-scoped import/BYOP password usage. |
| apis/v1alpha1/user_types.go | Shared parameter/observation types for User (incl. secret selectors). |
| apis/namespaced/user/v1alpha1/doc.go | Namespaced User API package metadata. |
| apis/namespaced/user/v1alpha1/groupversion_info.go | Namespaced User group/version registration. |
| apis/namespaced/user/v1alpha1/user_types.go | Namespaced User type definitions. |
| apis/namespaced/user/v1alpha1/zz_generated.deepcopy.go | Generated deepcopy for namespaced User types. |
| apis/namespaced/user/v1alpha1/zz_generated.managed.go | Generated managed-resource interface methods for namespaced User. |
| apis/namespaced/user/v1alpha1/zz_generated.managedlist.go | Generated managed list helper for namespaced UserList. |
| apis/namespaced/kafka.go | Adds namespaced User types to the namespaced API scheme. |
| apis/cluster/user/v1alpha1/doc.go | Cluster-scoped User API package metadata. |
| apis/cluster/user/v1alpha1/groupversion_info.go | Cluster-scoped User group/version registration. |
| apis/cluster/user/v1alpha1/user_types.go | Cluster-scoped User type definitions. |
| apis/cluster/user/v1alpha1/zz_generated.deepcopy.go | Generated deepcopy for cluster-scoped User types. |
| apis/cluster/user/v1alpha1/zz_generated.managed.go | Generated managed-resource interface methods for cluster-scoped User. |
| apis/cluster/user/v1alpha1/zz_generated.managedlist.go | Generated managed list helper for cluster-scoped UserList. |
| apis/cluster/kafka.go | Adds cluster-scoped User types to the cluster API scheme. |
Files not reviewed (6)
- apis/cluster/user/v1alpha1/zz_generated.deepcopy.go: Generated file
- apis/cluster/user/v1alpha1/zz_generated.managed.go: Generated file
- apis/cluster/user/v1alpha1/zz_generated.managedlist.go: Generated file
- apis/namespaced/user/v1alpha1/zz_generated.deepcopy.go: Generated file
- apis/namespaced/user/v1alpha1/zz_generated.managed.go: Generated file
- apis/namespaced/user/v1alpha1/zz_generated.managedlist.go: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Žan Ožbot <zan.ozbot@gmail.com>
Author
|
Resolved Copilot comments and rerun tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
Implements the
Usermanaged resource for managing Kafka SCRAM users in both cluster-scoped (user.kafka.crossplane.io/v1alpha1) and namespace-scoped (user.kafka.m.crossplane.io/v1alpha1) APIs.What the User resource does:
SCRAM-SHA-256,SCRAM-SHA-512; defaults toSCRAM-SHA-512)spec.forProvider.passwordSecretRefis omitted, and persists it in the connection Secretusername,password, andbrokersso applications have a single source of truth for Kafka credentialsObservemanagement policy for importing existing SCRAM users without resetting their credentialsI have:
make reviewable testto ensure this PR is ready for review.How has this code been tested
user_test.go: mechanism parsing,Exists,ObservedMechanisms,Upsert, `Delete``user_test.gocontrollers coveringObserve/Create/Update/Deletereconciliation paths, auto-password generation,passwordSecretRefresolution, and connection Secret contentsuser