-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_connection_cmd.go
More file actions
42 lines (36 loc) · 851 Bytes
/
test_connection_cmd.go
File metadata and controls
42 lines (36 loc) · 851 Bytes
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
39
40
41
42
package main
import (
"fmt"
"os"
"github.com/glestaris/issuez/domain"
"github.com/glestaris/issuez/tracker"
"github.com/spf13/cobra"
)
func init() {
rootCmd.AddCommand(testConnectionCmd)
}
var testConnectionCmd = &cobra.Command{
Use: "test-connection",
Short: "Tests JIRA connection",
Run: func(cmd *cobra.Command, args []string) {
trackerService, err := tracker.NewTrackerService(domain.Tracker{
Type: "jira",
Config: map[string]string{
"apiHost": jiraAPIHost,
"apiUsername": jiraAPIUsername,
"apiToken": jiraAPIToken,
},
})
if err != nil {
fmt.Printf(
"Failed to initialise tracker service for JIRA: %s\n", err,
)
os.Exit(1)
}
if err := trackerService.TestConnection(); err != nil {
fmt.Printf("Failed to connect to JIRA: %s\n", err)
os.Exit(1)
}
fmt.Println("OK")
},
}