// CreateIssue generates a JIRA issue from the various fields on the given GitHub issue, then
// sends it to the JIRA API.
CreateIssue generates a JIRA issue from the various fields on the given GitHub issue, then
sends it to the JIRA API.
// CreateIssue generates a JIRA issue from the various fields on the given GitHub issue then // sends it to the JIRA API .
func CreateIssue(config cfg.Config, issue github.Issue, ghClient clients.GitHubClient, jClient clients.JIRAClient) error {
	log := config.GetLogger()
	log.Debugf("Creating JIRA issue based on GitHub issue #%d", *issue.Number)
	fields := jira.IssueFields{
		Type: jira.IssueType{
			Name: config.GetIssueType(),
		},
		Project:     config.GetProject(),
		Summary:     issue.GetTitle(),
		Description: issue.GetBody(),
		Unknowns:    map[string]interface{}{},
	}
	fields.Unknowns[config.GetFieldKey(cfg.GitHubID)] = issue.GetID()
	fields.Unknowns[config.GetFieldKey(cfg.GitHubNumber)] = issue.GetNumber()
	fields.Unknowns[config.GetFieldKey(cfg.GitHubStatus)] = issue.GetState()
	fields.Unknowns[config.GetFieldKey(cfg.GitHubReporter)] = issue.User.GetLogin()
	strs := make([]string, len(issue.Labels))
	for i, v := range issue.Labels {
		strs[i] = *v.Name
	}
	fields.Unknowns[config.GetFieldKey(cfg.GitHubLabels)] = strings.Join(strs, ",")
	fields.Unknowns[config.GetFieldKey(cfg.LastISUpdate)] = time.Now().Format(dateFormat)
	jIssue := jira.Issue{
		Fields: &fields,
	}
	jIssue, err := jClient.CreateIssue(jIssue)
	if err != nil {
		return err
	}
	jIssue, err = jClient.GetIssue(jIssue.Key)
	if err != nil {
		return err
	}
	log.Debugf("Created JIRA issue %s!", jIssue.Key)
	if err := CompareComments(config, issue, jIssue, ghClient, jClient); err != nil {
		return err
	}
	return nil
}
func CreateIssue ( config cfg . Config , issue github . Issue , ghClient clients . GitHubClient , jClient clients . JIRAClient ) error { log := config . GetLogger ( ) log . Debugf ( " " , * issue . Number ) fields := jira . IssueFields { Type : jira . IssueType { Name : config . GetIssueType ( ) , } , Project : config . GetProject ( ) , Summary : issue . GetTitle ( ) , Description : issue . GetBody ( ) , Unknowns : map [ string ] interface { } { } , } fields . Unknowns [ config . GetFieldKey ( cfg . GitHubID ) ] = issue . GetID ( ) fields . Unknowns [ config . GetFieldKey ( cfg . GitHubNumber ) ] = issue . GetNumber ( ) fields . Unknowns [ config . GetFieldKey ( cfg . GitHubStatus ) ] = issue . GetState ( ) fields . Unknowns [ config . GetFieldKey ( cfg . GitHubReporter ) ] = issue . User . GetLogin ( ) strs := make ( [ ] string , len ( issue . Labels ) ) for i , v := range issue . Labels { strs [ i ] = * v . Name } fields . Unknowns [ config . GetFieldKey ( cfg . GitHubLabels ) ] = strings . Join ( strs , " " ) fields . Unknowns [ config . GetFieldKey ( cfg . LastISUpdate ) ] = time . Now ( ) . Format ( dateFormat ) jIssue := jira . Issue { Fields : & fields , } jIssue , err := jClient . CreateIssue ( jIssue ) if err != nil { return err } jIssue , err = jClient . GetIssue ( jIssue . Key ) if err != nil { return err } log . Debugf ( " " , jIssue . Key ) if err := CompareComments ( config , issue , jIssue , ghClient , jClient ) ; err != nil { return err } return nil }
CreateIssue generates a JIRA issue from the various fields on the given GitHub issue, then
sends it to the JIRA API.
CreateIssue generates a JIRA issue from the various fields on the given GitHub issue then sends it to the JIRA API .