Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] feat: added label and assignee to the create issue #692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions pkg/component/application/jira/v0/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type Issue struct {
Self string `json:"self"`
IssueType string `json:"issue-type"`
Status string `json:"status"`
Labels []string `json:"labels"`
Assignee string `json:"assignee"`
}

type GetIssueInput struct {
Expand All @@ -49,6 +51,22 @@ func extractIssue(issue *Issue) *Issue {
issue.Summary = summary
}
}
if len(issue.Labels) == 0 && issue.Fields["labels"] != nil {
if labels, ok := issue.Fields["labels"].([]interface{}); ok {
for _, label := range labels {
if strLabel, ok := label.(string); ok {
issue.Labels = append(issue.Labels, strLabel)
}
}
}
}
if issue.Assignee == "" && issue.Fields["assignee"] != nil {
if assignee, ok := issue.Fields["assignee"].(map[string]interface{}); ok {
if name, ok := assignee["name"].(string); ok {
issue.Assignee = name
}
}
}
if issue.IssueType == "" && issue.Fields["issuetype"] != nil {
if issueType, ok := issue.Fields["issuetype"]; ok {
if issue.IssueType, ok = issueType.(map[string]interface{})["name"].(string); !ok {
Expand Down Expand Up @@ -305,6 +323,8 @@ type CreateIssueInput struct {
IssueType IssueType `json:"issue-type"`
Summary string `json:"summary"`
Description string `json:"description"`
Labels []string `json:"labels"`
Assignee string `json:"assignee"`
}
type CreateIssueRequset struct {
Fields map[string]interface{} `json:"fields"`
Expand Down Expand Up @@ -340,6 +360,14 @@ func convertCreateIssueRequest(issue *CreateIssueInput) *CreateIssueRequset {
"description": issue.Description,
},
}
if len(issue.Labels) > 0 {
newRequest.Fields["labels"] = issue.Labels
}
if issue.Assignee != "" {
newRequest.Fields["assignee"] = map[string]string{
"name": issue.Assignee,
}
}
if issue.IssueType.ParentKey != "" {
newRequest.Fields["parent"] = map[string]interface{}{
"key": issue.IssueType.ParentKey,
Expand Down
Loading