mercari / tfnotify

A CLI command to parse Terraform execution result and notify it to GitHub
MIT License
619 stars 91 forks source link

Gitlab comments don't work #113

Open eremeevfd opened 2 years ago

eremeevfd commented 2 years ago

WHAT

Hello, excellent project! I'm very excited to use it in gitlab, but unfortunately I can't. Comments can't be posted to any gitlab mr.

WHY

I think that error is here: https://github.com/mercari/tfnotify/blob/a2897c6518b0e79fda3b03bafd95f887728b6f8a/notifier/gitlab/gitlab.go#L26

To be precise error-prone part is this:
fmt.Sprintf("%s/%s", g.namespace, g.project)

sprint here leads to incorrect api url:
https://gitlab.com/api/v4/projects/{namespace}/{project}/merge_requests/{mr}/notes

because gitlab doesn't have namespace and project, only project, so right url should look like this:

https://gitlab.com/api/v4/projects/{project}/merge_requests/{mr}/notes

also it should be mentioned that underlying gitlab client specifies this signature:
https://github.com/xanzy/go-gitlab/blob/41c6472d936a0ce5f919f7eb1afb8dc8ac46247a/notes.go#L477

func (s *NotesService) CreateMergeRequestNote(pid interface{}, mergeRequest int, opt *CreateMergeRequestNoteOptions, options ...RequestOptionFunc) (*Note, *Response, error) {

where pid is for project_id