feat(github): add github support
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-09 15:44:31 +02:00
parent 65fba21285
commit 89c1c72d87
11 changed files with 452 additions and 24 deletions

View File

@@ -10,11 +10,12 @@ import (
)
type BotHandler struct {
giteaClient *providers.GiteaClient
giteaClient *providers.GiteaClient
githubClient *providers.GitHubClient
}
func NewBotHandler(gitea *providers.GiteaClient) *BotHandler {
return &BotHandler{giteaClient: gitea}
func NewBotHandler(gitea *providers.GiteaClient, github *providers.GitHubClient) *BotHandler {
return &BotHandler{giteaClient: gitea, githubClient: github}
}
func (b *BotHandler) Handle(input string) (output string, err error) {
@@ -62,6 +63,14 @@ func (b *BotHandler) AppendComment(
repository string,
pullRequest int,
comment string,
backend models.SupportedBackend,
) (*models.AddCommentResponse, error) {
return b.giteaClient.AddComment(owner, repository, pullRequest, comment)
switch backend {
case models.SupportedBackendGitHub:
return b.githubClient.AddComment(owner, repository, pullRequest, comment)
case models.SupportedBackendGitea:
return b.giteaClient.AddComment(owner, repository, pullRequest, comment)
default:
panic("backend chosen was not a valid option")
}
}