-
Notifications
You must be signed in to change notification settings - Fork 1
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
gerrit-translator-cdevents : Plugin implementation to translate branch and repository events #1
Conversation
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
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.
@rjalander This looks like a good start. I have some questions and some ideas on how to make this a little more scalable.
cdEvent, err := sdk.NewRepositoryCreatedEvent() | ||
if err != nil { | ||
log.Printf("Error creating CDEvent RepositoryCreatedEvent %s\n", err) | ||
return "", err |
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.
One thing that might be appropriate to do is wrap these in our own Error
. I think a little digging is required here, but what do the errors look like when returned from the SDK?
For instance, if the error that is returned is something like error: pipe broken
than that's not too useful. Wrapping these errors with something that provides more context may be necessary
Right now we have two repos:
The plugin webhook adapter thingy and translator(s).
The webhook adapter can provide a set of Error
types that can be wrapped, and I think that would at least give some guidance on how the adapter should handle such errors, e.g. should we return a proper status code based on error type for example.
This will require some design, but I think it's an important call out and consideration.
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.
Will create an issue for handling these error scenarios and discuss design considerations here.
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.
@rjalander could you share a link to the issue?
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.
return cdEventStr, nil | ||
} | ||
|
||
func (projectHeadUpdated *ProjectHeadUpdated) RepositoryModifiedCDEvent() (string, error) { |
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.
Hmm, this seems a little odd, and I was thinking of a much different approach. Can you schedule a meeting with me? I want to go over some design consideration here
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
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.
Had just two comments, but I think we still need to go over the implementation of the go tags. It'll make this much easier in the future. Can you schedule something for this week?
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.
requesting some changes
Signed-off-by: Jalander Ramagiri <[email protected]>
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.
Just adding a comment about our prior meeting with Jalander and Andrew.
The goal is to utilize copygen
or some library that supports easy copying of structs without needing to manually write them ourselves.
There was some concerns around perfection and feature creep, so we decided that if we are unable to get struct tags in the go sdk by mid July, we will go ahead with the duplicated copying logic until struct tags exist.
created this PR cdevents/sdk-go#82 to support |
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.
Thanks for all the changes @rjalander. I will go ahead and approve this. The goal, however, is to eventually use some copier library to make it easy for translators to be developed. I will create a separate issue for that.
Thanks @xibz, We will address this issue and initiate a separate pull request to implement the copying of metadata utilizing a designated copier library. @afrittoli, could you please review this PR and approve it if there are no comments? |
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.
One thing that I noticed is that the plugin here returns CDEvents as JSON.
Currently the AsCloudEvent
function takes a CDEvent reader object as input, and there is no obvious way to send a JSON CDEvent as CloudEvent other than parsing it back into an object and using AsCloudEvent
.
Perhaps we'll need a new method in the SDK. or a different interface here
I tried using an interface which accepts And in |
Signed-off-by: Jalander Ramagiri <[email protected]>
I could not avoid having the There is a |
Ok, will use the same function |
@afrittoli, could you please approve it if there are no other comments? |
Implementation of
EventTranslator
interface that is exposed by CDEvents Webhook Adapter to translate gerrit events into CDEvents.This PR includes the changes to translate below Project and Branch related gerrit events into CDEvents, with the mappings as below
Note: Implementation as per the design RFC: gerrit-translator-cdevents-plugin and mapping events gerrit-cdevents
Signed-off-by: Jalander Ramagiri @rjalander