From 340c821a5bb417e41b3909e393d67d6787c19c69 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Thu, 5 Mar 2020 21:31:20 +0100 Subject: [PATCH] Add issue type to the campaign model --- cmd/init.go | 13 ++++++++----- jira/jira.go | 4 ++-- model/campaign.go | 13 +++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 71a1b71..038d676 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -25,6 +25,7 @@ func InitCmd() *cobra.Command { _ = cmd.MarkFlagRequired("summary") cmd.Flags().StringP("template", "t", "", "The template path for the description of the tickets") _ = cmd.MarkFlagRequired("template") + cmd.Flags().StringP("issue-type", "i", "Story", "The issue type to create the tickets as") return cmd } @@ -35,13 +36,15 @@ func initCmdF(cmd *cobra.Command, _ []string) { epic, _ := cmd.Flags().GetString("epic") summary, _ := cmd.Flags().GetString("summary") template, _ := cmd.Flags().GetString("template") + issueType, _ := cmd.Flags().GetString("issue-type") cmp := &model.Campaign{ - Url: url, - Project: project, - Epic: epic, - Summary: summary, - Template: template, + Url: url, + Project: project, + Epic: epic, + IssueType: issueType, + Summary: summary, + Template: template, } if err := campaign.Save(cmp); err != nil { ErrorAndExit(cmd, err) diff --git a/jira/jira.go b/jira/jira.go index 8923a18..33e39ac 100644 --- a/jira/jira.go +++ b/jira/jira.go @@ -41,7 +41,7 @@ func (c *JiraClient) GetIssueFromTicket(ticket *model.Ticket, campaign *model.Ca "Description": description, "Summary": summary, "Project": campaign.Project, - "Issue Type": "Story", + "Issue Type": campaign.IssueType, "Epic Link": campaign.Epic, } @@ -59,7 +59,7 @@ func (c *JiraClient) GetIssueFromTicket(ticket *model.Ticket, campaign *model.Ca return nil, fmt.Errorf("Error retrieving project with key %s", campaign.Project) } - issueType := project.GetIssueTypeWithName("Story") + issueType := project.GetIssueTypeWithName(campaign.IssueType) if issueType == nil { return nil, fmt.Errorf("Error retrieving issue type with name Story") } diff --git a/model/campaign.go b/model/campaign.go index 0bf6284..d9e9ca2 100644 --- a/model/campaign.go +++ b/model/campaign.go @@ -2,10 +2,11 @@ package model // ToDo: add key-value extra params as a map to allow for customfield_whatever = team type Campaign struct { - Url string `json:"url"` - Project string `json:"project"` - Epic string `json:"epic"` - Summary string `json:"summary"` - Template string `json:"template"` - Tickets []*Ticket `json:"tickets,omitempty"` + Url string `json:"url"` + Project string `json:"project"` + Epic string `json:"epic"` + IssueType string `json:"issue_type"` + Summary string `json:"summary"` + Template string `json:"template"` + Tickets []*Ticket `json:"tickets,omitempty"` }