Skip to content
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

Support enumerating the known event types #2863

Closed
evankanderson opened this issue Aug 8, 2023 · 1 comment · Fixed by #2865
Closed

Support enumerating the known event types #2863

evankanderson opened this issue Aug 8, 2023 · 1 comment · Fixed by #2865

Comments

@evankanderson
Copy link
Contributor

It looks like go-github has an internal list of all the GitHub event types . I'd like to be able to iterate over the list in my own code where I route events based on event type. I'm thinking of exposing the following methods:

// WebhookTypes returns a list of all the known GitHub event type strings supported by go-github.
func WebhookTypes() []string {
  // ...
}

// EventForType returns an empty struct matching the specified GitHub event type.
func EventForType(messageType string) any {

}

The second method would extract a lot of Event.ParsePayload https://github.com/google/go-github/blob/master/github/event.go#L30, so it wouldn't be much additional code.

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 9, 2023

I have no problem with that as long as you can refactor to reuse existing code as much as possible.
I say this because any time a new PR comes in to support a new webhook event type, it is a bit of a pain to make sure you tweak all the various places that need tweaking, and it would be nice to not add more pain to this process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants