jaws

package module
v0.0.0-...-777647f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2015 License: CC0-1.0 Imports: 10 Imported by: 0

README

Collection of small libraries for use with AWS. Added here to enable sharing and easier reuse.

jaws client

Top level is an AWS client. Very simple net/http like set of functions that use [go-aws-auth] (http://github.com/smartystreets/go-aws-auth) for AWS authentication, handles timeouts, and provides a way to easily create mocked responses.

userdata

A lib to parse a shell formatted EC2 user-data string of exported environment variables. It pulls the data from the instance metadata url (see below) and converts it to either a map[string]string struct or an slice of name/value structs (useful for json encoding).

metadata

A lib to access the meta-data of an EC2 AWS instance. It hits the local 169 address and caches the results. It is designed to return single values, not a struct of all the metadata.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Aws = New(true)
View Source
var BadStatus = errors.New("HTTP call failed bad status.")
View Source
var TimeoutError = errors.New("Timeout")

Functions

func NewAwsParams

func NewAwsParams(action, version string) url.Values

---------------------------------------------------------------------- utility functions

func NewReplies

func NewReplies(rs ...Reply) *replies

func ReadBody

func ReadBody(resp *http.Response) ([]byte, error)

util function to read the body of a response

func Testbody

func Testbody(b []byte) io.ReadCloser

func Timeout

func Timeout(t int) timeout

set time-out (default: in seconds)

Types

type Client

type Client struct {
	Cli doer
	// contains filtered or unexported fields
}

custom client to allow replacing doer for testing

func New

func New(sign bool) *Client

func (Client) Get

func (c Client) Get(url string) (*http.Response, error)

get + better do

func (Client) Post

func (c Client) Post(url string, data url.Values) (*http.Response, error)

post w/ content-type + better do

func (Client) Put

func (c Client) Put(url string, data io.Reader) (*http.Response, error)

put w/ content-type, date headers + better do

type Reply

type Reply struct {
	Status    int
	Body      []byte
	Reqtester func(*http.Request)
}

Reply implements the doer interface, so it can be swapped in for the http client in and return mock data for testing.

func (Reply) Do

func (r Reply) Do(req *http.Request) (*http.Response, error)

Mimics the behaviour of http.Client's Do() method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL