Skip to content

Conversation

@ChunyiLyu
Copy link
Contributor

@ChunyiLyu ChunyiLyu commented Sep 21, 2022

This closes #191

Note to reviewers: remember to look at the commits in this PR and consider if they can be squashed
Note to contributors: remember to re-generate client set if there are any API changes

Summary Of Changes

  • add CRD topicpermissions.rabbitmq.com and tested in integration and system tests
  • supports create/update/delete
  • vhost, exchange, and user information are immutable and required
  • since the logic to retrieve username from spec.userReference is the same as what's in PermissionReconciler, method r.getUserFromReference was refactored to getUsernameFromUser to reuse in topic permission reconciler.

Will squash when merging to clean up history.

Additional Context

)

// TopicPermissionSpec defines the desired state of TopicPermission
type TopicPermissionSpec struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We noticed that TopicPermissionSpec struct is identical to PermissionSpec of the Permission type. It would be possible to reuse it or maybe is good to have them separate for future extensions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structure of their the permission configurations are different: https://github.com/rabbitmq/messaging-topology-operator/blob/topic-permission-191/api/v1beta1/permission_types.go#L30-L37

User permissions needs configrue read and write, whereas topic permission is name of the exchange, read and write.

Expect(apierrors.IsInvalid(invalidPermission.ValidateCreate())).To(BeTrue())
})

It("does not allow both spec.rabbitmqClusterReference.name and spec.rabbitmqClusterReference.connectionSecret be configured", func() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were noticing that there are not reference of "connectionSecret" in topic_permission_webhook.go, where is this situation managed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,7 @@
apiVersion: rabbitmq.com/v1beta1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be here? We don't see the folder created on the repo.

Copy link
Contributor

@DanielePalaia DanielePalaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thank you very much. it looks in line with the other controllers. We just noticed that there is a file in samples/rabbitmq.com_v1beta1_topicpermission.yaml that shouldn't be there. From Daniele and @ablease!

@ChunyiLyu ChunyiLyu merged commit f140a4a into main Sep 26, 2022
@ChunyiLyu ChunyiLyu deleted the topic-permission-191 branch September 26, 2022 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Be able to create/update/delete topic permissions

4 participants