Skip to content

A Go client library for accessing the Azure DevOps API

License

Notifications You must be signed in to change notification settings

drmaxgit/go-azuredevops

 
 

Repository files navigation

go-azuredevops

GoDoc Build Status codecov Go Report Card

This is a fork of https://github.com/mcdafydd/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.

We forked this repo because we wanted to fix bug in atlantis - PR: runatlantis/atlantis#5298

Services

There is partial implementation for the following services:

  • Boards
  • Builds
  • Favourites
  • Git
  • Iterations
  • Pull Requests
  • Service Events (webhooks)
  • Tests
  • Users
  • Work Items

Usage

For usage with a personal access token, create a token using the process described here:

https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/pats?view=azure-devops

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)
}

OAuth

Instead of using a personal access token related to your personal user account, consider registering your app in Azure Devops:

https://docs.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/oauth?view=azure-devops

Supply a token generated from this process when you call NewClient().

Contributing

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.

Debugging

Add -tags debug to your go build to get some extra debug logging.

References

About

A Go client library for accessing the Azure DevOps API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.5%
  • Makefile 0.5%