diff --git a/pkg/git_provider/github.go b/pkg/git_provider/github.go index c0ac610a..323309f1 100644 --- a/pkg/git_provider/github.go +++ b/pkg/git_provider/github.go @@ -256,7 +256,7 @@ func (c *GithubClientImpl) HandlePayload(request *http.Request, secret []byte) ( PullRequestTitle: e.GetPullRequest().GetTitle(), PullRequestURL: e.GetPullRequest().GetHTMLURL(), DestBranch: e.GetPullRequest().GetBase().GetRef(), - Labels: e.GetPullRequest().Labels, + Labels: c.extractLabelNames(e.GetPullRequest().Labels), } case *github.CreateEvent: webhookPayload = &WebhookPayload{ @@ -297,3 +297,11 @@ func (c *GithubClientImpl) SetStatus(ctx *context.Context, repo *string, commit log.Printf("successfully set status on repo:%s commit: %s to status: %s\n", *repo, *commit, *status) return nil } + +func (c *GithubClientImpl) extractLabelNames(labels []*github.Label) []string { + var returnLabelsList []string + for _, label := range labels { + returnLabelsList = append(returnLabelsList, *label.Name) + } + return returnLabelsList +} diff --git a/pkg/git_provider/types.go b/pkg/git_provider/types.go index 2ef0c734..db3f055b 100644 --- a/pkg/git_provider/types.go +++ b/pkg/git_provider/types.go @@ -2,7 +2,6 @@ package git_provider import ( "context" - "github.com/google/go-github/v52/github" "net/http" ) @@ -12,17 +11,17 @@ type CommitFile struct { } type WebhookPayload struct { - Event string `json:"event"` - Action string `json:"action"` - Repo string `json:"repoName"` - Branch string `json:"branch"` - Commit string `json:"commit"` - User string `json:"user"` - UserEmail string `json:"user_email"` - PullRequestURL string `json:"pull_request_url"` - PullRequestTitle string `json:"pull_request_title"` - DestBranch string `json:"dest_branch"` - Labels []*github.Label `json:"Labels"` + Event string `json:"event"` + Action string `json:"action"` + Repo string `json:"repoName"` + Branch string `json:"branch"` + Commit string `json:"commit"` + User string `json:"user"` + UserEmail string `json:"user_email"` + PullRequestURL string `json:"pull_request_url"` + PullRequestTitle string `json:"pull_request_title"` + DestBranch string `json:"dest_branch"` + Labels []string `json:"Labels"` } type Client interface { diff --git a/pkg/workflow_handler/workflows.go b/pkg/workflow_handler/workflows.go index caf9f59a..ac9b08fc 100644 --- a/pkg/workflow_handler/workflows.go +++ b/pkg/workflow_handler/workflows.go @@ -174,11 +174,6 @@ func (wfc *WorkflowsClientImpl) HandleWorkflowBatch(ctx *context.Context, workfl } } - var prLabels []string - for _, label := range workflowsBatch.Payload.Labels { - prLabels = append(prLabels, label.GetName()) - } - globalParams := []v1alpha1.Parameter{ {Name: "event", Value: v1alpha1.AnyStringPtr(workflowsBatch.Payload.Event)}, {Name: "action", Value: v1alpha1.AnyStringPtr(workflowsBatch.Payload.Action)}, @@ -190,7 +185,7 @@ func (wfc *WorkflowsClientImpl) HandleWorkflowBatch(ctx *context.Context, workfl {Name: "pull_request_url", Value: v1alpha1.AnyStringPtr(workflowsBatch.Payload.PullRequestURL)}, {Name: "pull_request_title", Value: v1alpha1.AnyStringPtr(workflowsBatch.Payload.PullRequestTitle)}, {Name: "dest_branch", Value: v1alpha1.AnyStringPtr(workflowsBatch.Payload.DestBranch)}, - {Name: "pull_request_labels", Value: v1alpha1.AnyStringPtr(strings.Join(prLabels, ","))}, + {Name: "pull_request_labels", Value: v1alpha1.AnyStringPtr(strings.Join(workflowsBatch.Payload.Labels, ","))}, } params = append(params, globalParams...)