Working on Jira and Bugzilla issue in Project Almighty

I joined Red Hat on 15/06/2016.

I was assigned two issues on project Almighty to work on:

  1. Create simple example of fetching Issues from Jira in Go
  2. Create simple example of fetching Issues from Bugzilla in Go

I started with the Jira Issue. This was my first issue in golang. While solving this issue, i learnt the usage of “go get” command in golang. It downloads + installs an upstream package. For example, this is an upstream package which I used in the Jira Issue –> github.com/andygrunwald/go-jira

So, I installed+downloaded the package using following command:

go get github.com/andygrunwald/go-jira

The package got installed:

Screenshot from 2016-06-27 12-39-46

I learnt how to take input from command-line flags using “flag” package. To do this:

  • import flag package using:

import "flag"

  • Declare the variable in which you want to store the input

var username string
flag.StringVar(&username, "uname", "", "Username")

The first argument &uname is a pointer which stores the input value.
The second argument is the flag name which you use on the command line e.g. “-username”.
The third argument is the default value of the flag input.
The fourth argument is the description of the flag.

  • Parse the flag:

flag.Parse()

Next, I learnt to work with “net/http” package and how to parse http response in Go. Although I didnt use the package for this issue but I did experiment with it.

I used “reflect” package to find out the data type of http response. The two commands i used were:

reflect.TypeOf(result)
reflect.TypeOf(result).KindOf()

I found that http response have slice data type and each slice element had struct data type.

To access the value from struct data type, I had to find out its property name. For that, I used “reflect” package:
reflect.Indirect(result).FieldByName(field)

The next issue was bugzilla issue, The golang packages for bugzilla are listed here.

I used this package to get the results –> github.com/kolo/xmlrpc

XmlRpc is used to make remote procedure calls over HTTP.

The endpoint for xml-rpc interface is xmlrpc.cgi script in the bugzilla installation. So, for Red Hat Bugzilla, the endpoint is https://bugzilla.redhat.com/xmlrpc.cgi

You can find my code here.

Working on Jira and Bugzilla issue in Project Almighty