-
Notifications
You must be signed in to change notification settings - Fork 24
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
Quay notification support for ImageRepository #112
Conversation
Hi @Allda. Thanks for your PR. I'm waiting for a konflux-ci member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is missing removal of the notifications. As a user I can edit the CR and add/remove the notifications.
Will quay automatically cleanup notifications on the image repository deletion?
@@ -1,6 +1,8 @@ | |||
module github.com/redhat-appstudio/image-controller | |||
|
|||
go 1.20 | |||
go 1.21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to do the update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to run in locally with the previous version and since the new version was already available I bumped it up.
|
||
for _, notification := range imageRepository.Spec.Notifications { | ||
log.Info("Creating notification in Quay", "Title", notification.Title, "Event", notification.Event, "Method", notification.Method) | ||
quayNotification, err := r.QuayClient.CreateNotification( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will return an error if this function is called second time.
See how, for example, CreateRobotAccount
is implemented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated code to not create a duplicated entries if a notification already exists.
We currently don't have a planned workflow for the removal event. But yeah once the repo is removed all notifications are removed as well. |
func (r *ImageRepositoryReconciler) AddNotifications(ctx context.Context, imageRepository *imagerepositoryv1alpha1.ImageRepository) ([]imagerepositoryv1alpha1.NotificationStatus, error) { | ||
log := ctrllog.FromContext(ctx).WithName("ConfigureNotifications") | ||
|
||
if imageRepository.Spec.Notifications == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should check it before calling this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imageRepository.Spec.Notifications
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aha, I didn't want to add extra complexity to the parent function and instead return early from this one in case notifications are not set.
@@ -319,6 +364,11 @@ func (r *ImageRepositoryReconciler) ProvisionImageRepository(ctx context.Context | |||
} | |||
} | |||
|
|||
var notificationStatus []imagerepositoryv1alpha1.NotificationStatus | |||
if notificationStatus, err = r.AddNotifications(ctx, imageRepository); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to add the notifications on image repository creation only or at any point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the current usecase that we have it is fine to create a notification on CR creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to be implemented in follow up PR.
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To have a complete feature we have to implement editing and removing of the notifications.
But to not to block the functionality die date, we can merge this and improve later.
You can ignore EC failure, it's not related to the changes in this PR.
The ImageRepository CR is extended to allow defining a Quay notifications. The notification schema is based on Quay API schema and supports webhook and email configuration. Quay notification is created using the rest API client and added to a CR status field. JIRA: ISV-4756 Example: apiVersion: appstudio.redhat.com/v1alpha1 kind: ImageRepository metadata: name: imagerepository-sample namespace: image-controller-system spec: notifications: - title: MyNotif event: repo_push method: webhook config: url: https://foo.com Signed-off-by: Ales Raszka <[email protected]>
/ok-to-test |
The ImageRepository CR is extended to allow defining a Quay notifications. The notification schema is based on Quay API schema and supports webhook and email configuration.
Quay notification is created using the rest API client and added to a CR status field.
JIRA: ISV-4756
Example:
Update CR after a notification was set: