forked from git-chglog/git-chglog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira.go
38 lines (33 loc) · 828 Bytes
/
jira.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package chglog
import (
agjira "github.com/andygrunwald/go-jira"
)
// JiraClient is an HTTP client for Jira
type JiraClient interface {
GetJiraIssue(id string) (*agjira.Issue, error)
}
type jiraClient struct {
username string
token string
url string
}
// NewJiraClient returns an instance of JiraClient
func NewJiraClient(config *Config) JiraClient {
return jiraClient{
username: config.Options.JiraUsername,
token: config.Options.JiraToken,
url: config.Options.JiraURL,
}
}
func (jira jiraClient) GetJiraIssue(id string) (*agjira.Issue, error) {
tp := agjira.BasicAuthTransport{
Username: jira.username,
Password: jira.token,
}
client, err := agjira.NewClient(tp.Client(), jira.url)
if err != nil {
return nil, err
}
issue, _, err := client.Issue.Get(id, nil)
return issue, err
}