From cff9ce8adef0f3ddb4323c014df93ab0243623a3 Mon Sep 17 00:00:00 2001 From: Parth Sharma <86726240+parth-deepsource@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:18:36 +0530 Subject: [PATCH] feat: add support for specifying reporter id when creating Jira issues (#70) --- provider/jira/client.go | 5 +++++ provider/jira/jira.go | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/provider/jira/client.go b/provider/jira/client.go index 1377c7a..efa1576 100644 --- a/provider/jira/client.go +++ b/provider/jira/client.go @@ -55,6 +55,10 @@ type IssueType struct { HierarchyLevel int `json:"hierarchyLevel"` } +type Reporter struct { + ID string `json:"id,omitempty"` +} + type Fields struct { Project struct { Key string `json:"key"` @@ -62,6 +66,7 @@ type Fields struct { IssueType struct { ID string `json:"id"` } `json:"issuetype"` + Reporter *Reporter `json:"reporter,omitempty"` Summary string `json:"summary"` Description map[string]interface{} `json:"description"` } diff --git a/provider/jira/jira.go b/provider/jira/jira.go index 6e54e19..200c656 100644 --- a/provider/jira/jira.go +++ b/provider/jira/jira.go @@ -51,14 +51,20 @@ func (p *jiraSimple) Send(_ context.Context, notifier *domain.Notifier, body []b return nil, err } + reporter := (*Reporter)(nil) + if opts.ReporterID != "" { + reporter = &Reporter{ID: opts.ReporterID} + } + request := &CreateIssueRequest{ Fields: Fields{ Project: struct { - Key string "json:\"key\"" + Key string `json:"key"` }{Key: opts.ProjectKey}, IssueType: struct { - ID string "json:\"id\"" + ID string `json:"id"` }{ID: opts.IssueType}, + Reporter: reporter, Summary: payload.Summary, Description: payload.Description, }, @@ -225,6 +231,7 @@ type Opts struct { ProjectKey string `mapstructure:"project_key"` IssueType string `mapstructure:"issue_type"` CloudID string `mapstructure:"cloud_id"` + ReporterID string `mapstructure:"reporter_id"` } func (o *Opts) Extract(c *domain.NotifierConfiguration) domain.IError {