I'm working on this library to provide an interface between Atlantis and Azure Devops. This is my first project in Go. I'm happy to try and address issues and PRs in my spare time if you see areas that could use improvement.
My next steps:
- Make all function parameters and return values follow the same pattern
- Getting all the tests to run again
What I'd like to work on before calling it "good" for my needs:
- Document and test OAuth instead of a personal access token
- Add some integration tests with a public Azure Devops repo
This is a fork of https://github.com/benmatselby/go-azuredevops, a Go library for accessing the Azure DevOps API. As it develops, the library is looking more like of a port of go-github.
There is partial implementation for the following services:
- Boards
- Builds
- Favourites
- Git
- Iterations
- Pull Requests
- Service Events (webhooks)
- Tests
- Users
- Work Items
For usage with a personal access token, create a token using the process described here:
Add the token to a basic auth transport with an empty username:
tp := azuredevops.BasicAuthTransport{
Username: "",
Password: token,
}
Supply this token in calls to NewClient():
import "github.com/mcdafydd/go-azuredevops/azuredevops
client, _ := azuredevops.NewClient(tp.Client())
Get a list of iterations
iterations, error := v.Iterations.List(team)
if error != nil {
fmt.Println(error)
}
for index := 0; index < len(iterations); index++ {
fmt.Println(iterations[index].Name)
}
Instead of using a personal access token related to your personal user account, consider registering your app in Azure Devops:
Supply a token generated from this process when you call NewClient().
This library is re-using a lot of the code and style from the go-github library:
- Receiving struct members should be pointers google/go-github#19
- Debate on whether nillable fields are important for receiving structs, especially when also using separate request structs. Other popular libraries also use pointers approach, but it is often viewed as a big ugly. google/go-github#537
- Large receiving struct types should return []*Type, not []Type google/go-github#375
- Use omitempty in receiving struct JSON tags
- Pass context in API functions and Do() google/go-github#526
An exception to the pointer members are the count/value receiving structs used for responses containing multiple entities.
May add separate request structs soon.
Add -tags debug
to your go build to get some extra debug logging.