-
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
Part2: gerrit-translator-cdevents : translate patchset and change source code events #3
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
Signed-off-by: Jalander Ramagiri <[email protected]>
@afrittoli @xibz could you please review this PR and share your comments. |
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.
Most of my comments are very nit. So this can be a follow up PR to make it more idiomatic to Go
pkg/gerrit/event.go
Outdated
@@ -76,6 +76,26 @@ func (pEvent *GerritEvent) TranslateIntoCDEvent() (string, error) { | |||
if err != nil { | |||
return "", err | |||
} | |||
case "patchset-created": |
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.
These event types should probably be constants as that is more idiomatic to go even if they are only used here.
if refUpdated.RefUpdate.OldRev == "0000000000000000000000000000000000000000" { | ||
if strings.Contains(refUpdated.RefUpdate.RefName, "refs/changes") { | ||
Log().Info("Ignoring handling ref-updated gerrit event as this is followed by patchset/change events: ", refUpdated) | ||
return "", errors.New("ignoring translating ref-updated gerrit event") |
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 this 0000000000000000000000000000000000000000
a zeroe'd SHA?
We should also make this a constant. My guess is this is sent by gerrit?
pkg/gerrit/translate_events.go
Outdated
} | ||
Log().Info("PatchsetCreated GerritEvent received for project : ", patchsetCreated.Project.Name) | ||
patchsetCreated.RepoURL = pEvent.RepoURL | ||
if patchsetCreated.PatchSet.Number == 1 { |
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 noticed we have a lot of logs on the info level. I wonder if we should put some of these, if not most, in debugging.
Also this 1
could be a constant like const PatchSetCreatedNum = 1
or something
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.
Thanks for this PR.
The mapping that is documented in the PR description should also go into some docs for this plugin, so that one can know which event is mapped to what without having to parse the code.
Apart from that, I believe the Info
logging includes too much info, if this plugin was processing many events it would be too much, but this is something that could be tuned as a follow-up.
@@ -100,3 +100,103 @@ func (refUpdated *RefUpdated) BranchDeletedCDEvent() (string, error) { | |||
} | |||
return cdEventStr, nil | |||
} | |||
|
|||
func (patchsetCreated *PatchsetCreated) ChangeCreatedCDEvent() (string, error) { | |||
Log().Info("Creating CDEvent ChangeCreatedEvent") |
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.
Having Info
log level for each event created will spam logs without providing much value as the text is fixed. I would make this Debug
and provide at least the event ID in there
if err != nil { | ||
return "", err | ||
} | ||
Log().Info("Translated patchset-created gerrit event into dev.cdevents.change.created CDEvent: ", cdEvent) |
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 Info
is too much here too.
This PR includes the changes to translate below Patchset and Change 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