Skip to content

Commit

Permalink
Add reporter validation to ClearReports (#462)
Browse files Browse the repository at this point in the history
  • Loading branch information
gjonathanhong authored Dec 16, 2024
1 parent 936dc16 commit 38cb11a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/platform/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func (g *GitLab) StoragePrefix(ctx context.Context) (string, error) {

// ListReports lists existing reports for an issue or change request.
func (g *GitLab) ListReports(ctx context.Context, opts *ListReportsOptions) (*ListReportsResult, error) {
if err := validateGitLabReporterInputs(g.cfg); err != nil {
return nil, fmt.Errorf("failed to validate reporter inputs: %w", err)
}

var reports []*Report
var pagination *Pagination

Expand Down Expand Up @@ -232,6 +236,10 @@ func (g *GitLab) ListReports(ctx context.Context, opts *ListReportsOptions) (*Li

// DeleteReport deletes an existing comment from an issue or change request.
func (g *GitLab) DeleteReport(ctx context.Context, id any) error {
if err := validateGitLabReporterInputs(g.cfg); err != nil {
return fmt.Errorf("failed to validate reporter inputs: %w", err)
}

noteID, ok := id.(int)
if !ok {
return fmt.Errorf("expected note id of type int")
Expand Down Expand Up @@ -293,6 +301,10 @@ func (g *GitLab) ReportEntrypointsSummary(ctx context.Context, p *EntrypointsSum

// ClearReports clears any existing reports that can be removed.
func (g *GitLab) ClearReports(ctx context.Context) error {
if err := validateGitLabReporterInputs(g.cfg); err != nil {
return fmt.Errorf("failed to validate reporter inputs: %w", err)
}

listOpts := &ListReportsOptions{
GitLab: &gitlab.ListMergeRequestNotesOptions{
ListOptions: gitlab.ListOptions{PerPage: 100},
Expand Down

0 comments on commit 38cb11a

Please sign in to comment.