open-nomad/vendor/github.com/packethost/packngo
Seth Hoenig 435c0d9fc8 deps: Switch to Go modules for dependency management
This PR switches the Nomad repository from using govendor to Go modules
for managing dependencies. Aspects of the Nomad workflow remain pretty
much the same. The usual Makefile targets should continue to work as
they always did. The API submodule simply defers to the parent Nomad
version on the repository, keeping the semantics of API versioning that
currently exists.
2020-06-02 14:30:36 -05:00
..
.drone.yml deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
.gitignore deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
CHANGELOG.md deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
LICENSE.txt deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
README.md deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
billing_address.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
devices.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
email.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
facilities.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
ip.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
operatingsystems.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
organizations.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
packngo.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
payment_methods.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
plans.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
ports.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
projects.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
rate.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
spotmarket.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
sshkeys.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
timestamp.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
user.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
utils.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
virtualnetworks.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00
volumes.go deps: Switch to Go modules for dependency management 2020-06-02 14:30:36 -05:00

README.md

packngo

Packet Go Api Client

Installation

go get github.com/packethost/packngo

Usage

To authenticate to the Packet API, you must have your API token exported in env var PACKET_API_TOKEN.

This code snippet initializes Packet API client, and lists your Projects:

package main

import (
	"log"

	"github.com/packethost/packngo"
)

func main() {
	c, err := packngo.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	ps, _, err := c.Projects.List(nil)
	if err != nil {
		log.Fatal(err)
	}
	for _, p := range ps {
		log.Println(p.ID, p.Name)
	}
}

This lib is used by the official terraform-provider-packet.

You can also learn a lot from the *_test.go sources. Almost all out tests touch the Packet API, so you can see how auth, querying and POSTing works. For example devices_test.go.

Acceptance Tests

If you want to run tests against the actual Packet API, you must set envvar PACKET_TEST_ACTUAL_API to non-empty string for the go test. The device tests wait for the device creation, so it's best to run a few in parallel.

To run a particular test, you can do

$ PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccDeviceBasic

If you want to see HTTP requests, set the PACKNGO_DEBUG env var to non-empty string, for example:

$ PACKNGO_DEBUG=1 PACKNGO_TEST_ACTUAL_API=1 go test -v -run=TestAccVolumeUpdate

Committing

Before committing, it's a good idea to run gofmt -w *.go. (gofmt)