├── .gitignore ├── Godeps ├── _workspace │ ├── .gitignore │ └── src │ │ ├── github.com │ │ ├── fsouza │ │ │ └── go-dockerclient │ │ │ │ ├── testing │ │ │ │ ├── data │ │ │ │ │ ├── barfile │ │ │ │ │ ├── foofile │ │ │ │ │ ├── symlink │ │ │ │ │ ├── .dockerignore │ │ │ │ │ ├── Dockerfile │ │ │ │ │ ├── ca.pem │ │ │ │ │ ├── cert.pem │ │ │ │ │ ├── server.pem │ │ │ │ │ ├── key.pem │ │ │ │ │ ├── serverkey.pem │ │ │ │ │ ├── container.tar │ │ │ │ │ └── dockerfile.tar │ │ │ │ ├── bin │ │ │ │ │ └── fmtpolice │ │ │ │ └── writer.go │ │ │ │ ├── vendor │ │ │ │ └── github.com │ │ │ │ │ ├── docker │ │ │ │ │ └── docker │ │ │ │ │ │ └── pkg │ │ │ │ │ │ ├── archive │ │ │ │ │ │ ├── README.md │ │ │ │ │ │ ├── time_unsupported.go │ │ │ │ │ │ ├── time_linux.go │ │ │ │ │ │ ├── archive_windows.go │ │ │ │ │ │ ├── archive_unix.go │ │ │ │ │ │ ├── archive_unix_test.go │ │ │ │ │ │ ├── wrap.go │ │ │ │ │ │ ├── archive_windows_test.go │ │ │ │ │ │ ├── wrap_test.go │ │ │ │ │ │ └── example_changes.go │ │ │ │ │ │ ├── system │ │ │ │ │ │ ├── meminfo_unsupported.go │ │ │ │ │ │ ├── errors.go │ │ │ │ │ │ ├── filesys.go │ │ │ │ │ │ ├── lstat_windows.go │ │ │ │ │ │ ├── umask.go │ │ │ │ │ │ ├── umask_windows.go │ │ │ │ │ │ ├── utimes_darwin.go │ │ │ │ │ │ ├── xattrs_unsupported.go │ │ │ │ │ │ ├── utimes_unsupported.go │ │ │ │ │ │ ├── mknod_windows.go │ │ │ │ │ │ ├── stat_unsupported.go │ │ │ │ │ │ ├── stat_windows.go │ │ │ │ │ │ ├── lstat.go │ │ │ │ │ │ ├── meminfo.go │ │ │ │ │ │ ├── utimes_freebsd.go │ │ │ │ │ │ ├── lstat_test.go │ │ │ │ │ │ ├── stat_linux.go │ │ │ │ │ │ ├── mknod.go │ │ │ │ │ │ ├── utimes_linux.go │ │ │ │ │ │ ├── stat_test.go │ │ │ │ │ │ ├── stat.go │ │ │ │ │ │ ├── meminfo_linux_test.go │ │ │ │ │ │ ├── filesys_windows.go │ │ │ │ │ │ ├── utimes_test.go │ │ │ │ │ │ ├── meminfo_linux.go │ │ │ │ │ │ └── xattrs_linux.go │ │ │ │ │ │ ├── promise │ │ │ │ │ │ └── promise.go │ │ │ │ │ │ ├── ioutils │ │ │ │ │ │ ├── writeflusher.go │ │ │ │ │ │ ├── writers.go │ │ │ │ │ │ └── writers_test.go │ │ │ │ │ │ ├── units │ │ │ │ │ │ ├── duration.go │ │ │ │ │ │ ├── duration_test.go │ │ │ │ │ │ └── size.go │ │ │ │ │ │ └── stdcopy │ │ │ │ │ │ └── stdcopy_test.go │ │ │ │ │ ├── Sirupsen │ │ │ │ │ └── logrus │ │ │ │ │ │ ├── terminal_openbsd.go │ │ │ │ │ │ ├── CHANGELOG.md │ │ │ │ │ │ ├── terminal_linux.go │ │ │ │ │ │ ├── terminal_darwin.go │ │ │ │ │ │ ├── terminal_freebsd.go │ │ │ │ │ │ ├── terminal_notwindows.go │ │ │ │ │ │ ├── writer.go │ │ │ │ │ │ ├── terminal_windows.go │ │ │ │ │ │ ├── json_formatter.go │ │ │ │ │ │ ├── LICENSE │ │ │ │ │ │ ├── hooks.go │ │ │ │ │ │ ├── entry_test.go │ │ │ │ │ │ ├── formatter.go │ │ │ │ │ │ ├── text_formatter_test.go │ │ │ │ │ │ ├── formatter_bench_test.go │ │ │ │ │ │ ├── logrus.go │ │ │ │ │ │ ├── hook_test.go │ │ │ │ │ │ └── json_formatter_test.go │ │ │ │ │ └── gorilla │ │ │ │ │ ├── mux │ │ │ │ │ ├── README.md │ │ │ │ │ ├── bench_test.go │ │ │ │ │ └── LICENSE │ │ │ │ │ └── context │ │ │ │ │ ├── README.md │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── doc.go │ │ │ │ ├── .travis.yml │ │ │ │ ├── DOCKER-LICENSE │ │ │ │ ├── change_test.go │ │ │ │ ├── Makefile │ │ │ │ ├── change.go │ │ │ │ ├── LICENSE │ │ │ │ ├── auth_test.go │ │ │ │ ├── signal.go │ │ │ │ ├── misc.go │ │ │ │ ├── README.markdown │ │ │ │ ├── auth.go │ │ │ │ ├── tls.go │ │ │ │ └── AUTHORS │ │ ├── codegangsta │ │ │ └── cli │ │ │ │ ├── .travis.yml │ │ │ │ ├── autocomplete │ │ │ │ ├── zsh_autocomplete │ │ │ │ └── bash_autocomplete │ │ │ │ ├── helpers_test.go │ │ │ │ ├── cli.go │ │ │ │ ├── LICENSE │ │ │ │ ├── command_test.go │ │ │ │ ├── context_test.go │ │ │ │ └── cli_test.go │ │ ├── mb0 │ │ │ └── glob │ │ │ │ ├── README.md │ │ │ │ └── LICENSE │ │ ├── remind101 │ │ │ └── pkg │ │ │ │ ├── logger │ │ │ │ ├── example_test.go │ │ │ │ └── logger_test.go │ │ │ │ ├── reporter │ │ │ │ ├── util │ │ │ │ │ └── util.go │ │ │ │ ├── fallback.go │ │ │ │ ├── hb │ │ │ │ │ ├── example_test.go │ │ │ │ │ ├── test-fixtures │ │ │ │ │ │ ├── boom-typed.json │ │ │ │ │ │ ├── boom.json │ │ │ │ │ │ ├── boom-request.json │ │ │ │ │ │ └── boom-more.json │ │ │ │ │ ├── hb_test.go │ │ │ │ │ └── hb.go │ │ │ │ ├── multi.go │ │ │ │ ├── fallback_test.go │ │ │ │ ├── logger.go │ │ │ │ ├── logger_test.go │ │ │ │ ├── nr │ │ │ │ │ ├── nr.go │ │ │ │ │ └── nr_test.go │ │ │ │ ├── multi_test.go │ │ │ │ └── reporter_test.go │ │ │ │ └── trace │ │ │ │ ├── example_test.go │ │ │ │ ├── trace_test.go │ │ │ │ └── trace.go │ │ └── quipo │ │ │ └── statsd │ │ │ ├── event │ │ │ ├── interface.go │ │ │ ├── total.go │ │ │ ├── increment.go │ │ │ ├── absolute.go │ │ │ ├── fabsolute.go │ │ │ ├── gauge.go │ │ │ ├── fgauge.go │ │ │ ├── gaugedelta.go │ │ │ ├── fgaugedelta.go │ │ │ ├── timing.go │ │ │ └── precisiontiming.go │ │ │ ├── interface.go │ │ │ ├── LICENSE │ │ │ ├── noopclient.go │ │ │ └── README.md │ │ ├── code.google.com │ │ └── p │ │ │ └── go-uuid │ │ │ └── uuid │ │ │ ├── doc.go │ │ │ ├── version4.go │ │ │ ├── version1.go │ │ │ ├── LICENSE │ │ │ ├── hash.go │ │ │ ├── util.go │ │ │ ├── dce.go │ │ │ └── node.go │ │ └── golang.org │ │ └── x │ │ └── net │ │ └── context │ │ └── withtimeout_test.go ├── Readme └── Godeps.json ├── docker-compose.yml ├── Makefile ├── .travis.yml ├── Dockerfile ├── bin └── build ├── stat.go ├── adapter_test.go ├── cmd └── stats │ └── main.go ├── README.md └── adapter.go /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .vagrant 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | /bin 3 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/barfile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/foofile: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/symlink: -------------------------------------------------------------------------------- 1 | doesnotexist -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | stat: 2 | build: ./ 3 | environment: 4 | DOCKER_HOST: 5 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/.dockerignore: -------------------------------------------------------------------------------- 1 | container.tar 2 | dockerfile.tar 3 | foofile 4 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.1 3 | 4 | script: 5 | - go vet ./... 6 | - go test -v ./... 7 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: cmd build 2 | 3 | cmd: 4 | godep go build -o build/stats ./cmd/stats 5 | 6 | build: Dockerfile 7 | docker build --no-cache -t remind101/dockerstats . 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/README.md: -------------------------------------------------------------------------------- 1 | This code provides helper functions for dealing with archive files. 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.4 4 | install: 5 | - export PATH=$PATH:$HOME/gopath/bin 6 | - go get -v -u github.com/tools/godep 7 | script: 8 | - godep go test ./... 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.3.1 4 | - 1.4 5 | - tip 6 | env: 7 | - GOARCH=amd64 8 | - GOARCH=386 9 | script: 10 | - make test 11 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/zsh_autocomplete: -------------------------------------------------------------------------------- 1 | autoload -U compinit && compinit 2 | autoload -U bashcompinit && bashcompinit 3 | 4 | script_dir=$(dirname $0) 5 | source ${script_dir}/bash_autocomplete 6 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_openbsd.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "syscall" 4 | 5 | const ioctlReadTermios = syscall.TIOCGETA 6 | 7 | type Termios syscall.Termios 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/meminfo_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package system 4 | 5 | func ReadMemInfo() (*MemInfo, error) { 6 | return nil, ErrNotSupportedPlatform 7 | } 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/errors.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | var ( 8 | ErrNotSupportedPlatform = errors.New("platform and architecture is not supported") 9 | ) 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mb0/glob/README.md: -------------------------------------------------------------------------------- 1 | glob 2 | ==== 3 | 4 | A configurable globbing and matching algorithm for go. 5 | 6 | The package is based on the globbing and matching code from package path/filepath. 7 | 8 | Documentation at http://godoc.org/github.com/mb0/glob 9 | 10 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/filesys.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | ) 8 | 9 | func MkdirAll(path string, perm os.FileMode) error { 10 | return os.MkdirAll(path, perm) 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/lstat_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | func Lstat(path string) (*Stat_t, error) { 6 | // should not be called on cli code path 7 | return nil, ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/umask.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | func Umask(newmask int) (oldmask int, err error) { 10 | return syscall.Umask(newmask), nil 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/umask_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | func Umask(newmask int) (oldmask int, err error) { 6 | // should not be called on cli code path 7 | return 0, ErrNotSupportedPlatform 8 | } 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.1 2 | MAINTAINER Eric Holmes 3 | 4 | ENV DOCKER_HOST unix:///var/run/docker.sock 5 | 6 | COPY ./ /go/src/github.com/remind101/dockerstats 7 | COPY ./bin/build /build 8 | RUN /build 9 | WORKDIR /go/src/github.com/remind101/dockerstats 10 | 11 | ENTRYPOINT ["stats"] 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.8 2 | 3 | logrus: defaults to stderr instead of stdout 4 | 5 | # 0.7.3 6 | 7 | formatter/\*: allow configuration of timestamp layout 8 | 9 | # 0.7.2 10 | 11 | formatter/text: Add configuration option for time format (#158) 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/mux/README.md: -------------------------------------------------------------------------------- 1 | mux 2 | === 3 | [![Build Status](https://travis-ci.org/gorilla/mux.png?branch=master)](https://travis-ci.org/gorilla/mux) 4 | 5 | gorilla/mux is a powerful URL router and dispatcher. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/mux 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/DOCKER-LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | You can find the Docker license at the following link: 6 | https://raw.githubusercontent.com/docker/docker/master/LICENSE 7 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The uuid package generates and inspects UUIDs. 6 | // 7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services. 8 | package uuid 9 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/utimes_darwin.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import "syscall" 4 | 5 | func LUtimesNano(path string, ts []syscall.Timespec) error { 6 | return ErrNotSupportedPlatform 7 | } 8 | 9 | func UtimesNano(path string, ts []syscall.Timespec) error { 10 | return syscall.UtimesNano(path, ts) 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/logger/example_test.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func ExampleLogger_Log() { 9 | l := New(log.New(os.Stdout, "", 0)) 10 | 11 | // Consecutive arguments after the message are treated as key value pairs. 12 | l.Info("message", "key", "value") 13 | 14 | // Output: 15 | // message key=value 16 | } 17 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/util/util.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "reflect" 5 | "runtime" 6 | ) 7 | 8 | func ClassName(err error) string { 9 | return reflect.TypeOf(err).String() 10 | } 11 | 12 | func FunctionName(pc uintptr) string { 13 | fn := runtime.FuncForPC(pc) 14 | if fn == nil { 15 | return "???" 16 | } 17 | return fn.Name() 18 | } 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/xattrs_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package system 4 | 5 | func Lgetxattr(path string, attr string) ([]byte, error) { 6 | return nil, ErrNotSupportedPlatform 7 | } 8 | 9 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 10 | return ErrNotSupportedPlatform 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/time_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux 2 | 3 | package archive 4 | 5 | import ( 6 | "syscall" 7 | "time" 8 | ) 9 | 10 | func timeToTimespec(time time.Time) (ts syscall.Timespec) { 11 | nsec := int64(0) 12 | if !time.IsZero() { 13 | nsec = time.UnixNano() 14 | } 15 | return syscall.NsecToTimespec(nsec) 16 | } 17 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/utimes_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!freebsd,!darwin 2 | 3 | package system 4 | 5 | import "syscall" 6 | 7 | func LUtimesNano(path string, ts []syscall.Timespec) error { 8 | return ErrNotSupportedPlatform 9 | } 10 | 11 | func UtimesNano(path string, ts []syscall.Timespec) error { 12 | return ErrNotSupportedPlatform 13 | } 14 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/promise/promise.go: -------------------------------------------------------------------------------- 1 | package promise 2 | 3 | // Go is a basic promise implementation: it wraps calls a function in a goroutine, 4 | // and returns a channel which will later return the function's return value. 5 | func Go(f func() error) chan error { 6 | ch := make(chan error, 1) 7 | go func() { 8 | ch <- f() 9 | }() 10 | return ch 11 | } 12 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_darwin.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TIOCGETA 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/time_linux.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "syscall" 5 | "time" 6 | ) 7 | 8 | func timeToTimespec(time time.Time) (ts syscall.Timespec) { 9 | if time.IsZero() { 10 | // Return UTIME_OMIT special value 11 | ts.Sec = 0 12 | ts.Nsec = ((1 << 30) - 2) 13 | return 14 | } 15 | return syscall.NsecToTimespec(time.UnixNano()) 16 | } 17 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/mknod_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | func Mknod(path string, mode uint32, dev int) error { 6 | // should not be called on cli code path 7 | return ErrNotSupportedPlatform 8 | } 9 | 10 | func Mkdev(major int64, minor int64) uint32 { 11 | panic("Mkdev not implemented on windows, should not be called on cli code") 12 | } 13 | -------------------------------------------------------------------------------- /bin/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "@edge http://dl-4.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories 4 | packages="curl git go@edge" 5 | 6 | apk add --update curl git go@edge 7 | 8 | export GOPATH=/go 9 | go get github.com/tools/godep 10 | cd /go/src/github.com/remind101/dockerstats 11 | /go/bin/godep go install github.com/remind101/dockerstats/cmd/stats 12 | mv /go/bin/stats /bin 13 | 14 | apk del curl git go 15 | rm -rf /var/cache/apk/* 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/autocomplete/bash_autocomplete: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | _cli_bash_autocomplete() { 4 | local cur prev opts base 5 | COMPREPLY=() 6 | cur="${COMP_WORDS[COMP_CWORD]}" 7 | prev="${COMP_WORDS[COMP_CWORD-1]}" 8 | opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) 9 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 10 | return 0 11 | } 12 | 13 | complete -F _cli_bash_autocomplete $PROG -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/stat_unsupported.go: -------------------------------------------------------------------------------- 1 | // +build !linux,!windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // fromStatT creates a system.Stat_t type from a syscall.Stat_t type 10 | func fromStatT(s *syscall.Stat_t) (*Stat_t, error) { 11 | return &Stat_t{size: s.Size, 12 | mode: uint32(s.Mode), 13 | uid: s.Uid, 14 | gid: s.Gid, 15 | rdev: uint64(s.Rdev), 16 | mtim: s.Mtimespec}, nil 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/stat_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "errors" 7 | "syscall" 8 | ) 9 | 10 | func fromStatT(s *syscall.Win32FileAttributeData) (*Stat_t, error) { 11 | return nil, errors.New("fromStatT should not be called on windows path") 12 | } 13 | 14 | func Stat(path string) (*Stat_t, error) { 15 | // should not be called on cli code path 16 | return nil, ErrNotSupportedPlatform 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_freebsd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin. 3 | */ 4 | package logrus 5 | 6 | import ( 7 | "syscall" 8 | ) 9 | 10 | const ioctlReadTermios = syscall.TIOCGETA 11 | 12 | type Termios struct { 13 | Iflag uint32 14 | Oflag uint32 15 | Cflag uint32 16 | Lflag uint32 17 | Cc [20]uint8 18 | Ispeed uint32 19 | Ospeed uint32 20 | } 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/lstat.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Lstat takes a path to a file and returns 10 | // a system.Stat_t type pertaining to that file. 11 | // 12 | // Throws an error if the file does not exist 13 | func Lstat(path string) (*Stat_t, error) { 14 | s := &syscall.Stat_t{} 15 | if err := syscall.Lstat(path, s); err != nil { 16 | return nil, err 17 | } 18 | return fromStatT(s) 19 | } 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/meminfo.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | // MemInfo contains memory statistics of the host system. 4 | type MemInfo struct { 5 | // Total usable RAM (i.e. physical RAM minus a few reserved bits and the 6 | // kernel binary code). 7 | MemTotal int64 8 | 9 | // Amount of free memory. 10 | MemFree int64 11 | 12 | // Total amount of swap space available. 13 | SwapTotal int64 14 | 15 | // Amount of swap space that is currently unused. 16 | SwapFree int64 17 | } 18 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/helpers_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | /* Test Helpers */ 9 | func expect(t *testing.T, a interface{}, b interface{}) { 10 | if a != b { 11 | t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 12 | } 13 | } 14 | 15 | func refute(t *testing.T, a interface{}, b interface{}) { 16 | if a == b { 17 | t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a)) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/fallback.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import "golang.org/x/net/context" 4 | 5 | type FallbackReporter struct { 6 | // The first reporter to call. 7 | Reporter Reporter 8 | 9 | // This reporter will be used to report an error if the first Reporter 10 | // fails for some reason. 11 | Fallback Reporter 12 | } 13 | 14 | func (r *FallbackReporter) Report(ctx context.Context, err error) error { 15 | if err2 := r.Reporter.Report(ctx, err); err2 != nil { 16 | r.Fallback.Report(ctx, err2) 17 | return err2 18 | } 19 | 20 | return nil 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/trace/example_test.go: -------------------------------------------------------------------------------- 1 | package trace_test 2 | 3 | import ( 4 | "github.com/remind101/pkg/logger" 5 | "github.com/remind101/pkg/trace" 6 | "golang.org/x/net/context" 7 | ) 8 | 9 | func ping(ctx context.Context) (err error) { 10 | ctx, done := trace.Trace(ctx) 11 | defer done(nil, "pong") 12 | 13 | return 14 | } 15 | 16 | func Example() { 17 | ctx := context.Background() 18 | ctx = logger.WithLogger(ctx, logger.Stdout) 19 | ping(ctx) 20 | 21 | // pong trace.id= 22 | // trace.func=github.com/remind101/pkg/trace_test.ping trace.file=... trace.line=10 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/interface.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | // constant event type identifiers 4 | const ( 5 | EventIncr = iota 6 | EventTiming 7 | EventAbsolute 8 | EventTotal 9 | EventGauge 10 | EventGaugeDelta 11 | EventFGauge 12 | EventFGaugeDelta 13 | EventFAbsolute 14 | EventPrecisionTiming 15 | ) 16 | 17 | // Event is an interface to a generic StatsD event, used by the buffered client collator 18 | type Event interface { 19 | Stats() []string 20 | Type() int 21 | TypeString() string 22 | Payload() interface{} 23 | Update(e2 Event) error 24 | String() string 25 | Key() string 26 | SetKey(string) 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/mux/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package mux 6 | 7 | import ( 8 | "net/http" 9 | "testing" 10 | ) 11 | 12 | func BenchmarkMux(b *testing.B) { 13 | router := new(Router) 14 | handler := func(w http.ResponseWriter, r *http.Request) {} 15 | router.HandleFunc("/v1/{v1}", handler) 16 | 17 | request, _ := http.NewRequest("GET", "/v1/anything", nil) 18 | for i := 0; i < b.N; i++ { 19 | router.ServeHTTP(nil, request) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/example_test.go: -------------------------------------------------------------------------------- 1 | package hb_test 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | 7 | "github.com/remind101/pkg/reporter" 8 | "github.com/remind101/pkg/reporter/hb" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | var errBoom = errors.New("boom") 13 | 14 | func Example() { 15 | ctx := reporter.WithReporter(context.Background(), hb.NewReporter("dcb8affa")) 16 | req, _ := http.NewRequest("GET", "/api/foo", nil) 17 | req.Header.Set("Content-Type", "application/json") 18 | 19 | reporter.AddContext(ctx, "request_id", "1234") 20 | reporter.AddRequest(ctx, req) 21 | reporter.Report(ctx, errBoom) 22 | // Output: 23 | } 24 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/utimes_freebsd.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | func LUtimesNano(path string, ts []syscall.Timespec) error { 9 | var _path *byte 10 | _path, err := syscall.BytePtrFromString(path) 11 | if err != nil { 12 | return err 13 | } 14 | 15 | if _, _, err := syscall.Syscall(syscall.SYS_LUTIMES, uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), 0); err != 0 && err != syscall.ENOSYS { 16 | return err 17 | } 18 | 19 | return nil 20 | } 21 | 22 | func UtimesNano(path string, ts []syscall.Timespec) error { 23 | return syscall.UtimesNano(path, ts) 24 | } 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/test-fixtures/boom-typed.json: -------------------------------------------------------------------------------- 1 | { 2 | "notifier": { 3 | "name": "Honeybadger (Go)", 4 | "url": "https://github.com/remind101/pkg/reporter/hb", 5 | "version": "0.1", 6 | "language": "Go" 7 | }, 8 | "error": { 9 | "class": "*hb.typedError", 10 | "message": "boom", 11 | "backtrace": [], 12 | "source": {}, 13 | "tags": null 14 | }, 15 | "request": { 16 | "url": "", 17 | "component": "", 18 | "action": "", 19 | "params": {}, 20 | "session": {}, 21 | "cgi_data": {}, 22 | "context": {} 23 | }, 24 | "server": { 25 | "project_root": {}, 26 | "environment_name": "", 27 | "hostname": "" 28 | } 29 | } -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/test-fixtures/boom.json: -------------------------------------------------------------------------------- 1 | { 2 | "notifier": { 3 | "name": "Honeybadger (Go)", 4 | "url": "https://github.com/remind101/pkg/reporter/hb", 5 | "version": "0.1", 6 | "language": "Go" 7 | }, 8 | "error": { 9 | "class": "*errors.errorString", 10 | "message": "boom", 11 | "backtrace": [], 12 | "source": {}, 13 | "tags": null 14 | }, 15 | "request": { 16 | "url": "", 17 | "component": "", 18 | "action": "", 19 | "params": {}, 20 | "session": {}, 21 | "cgi_data": {}, 22 | "context": {} 23 | }, 24 | "server": { 25 | "project_root": {}, 26 | "environment_name": "", 27 | "hostname": "" 28 | } 29 | } -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/multi.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import "golang.org/x/net/context" 4 | 5 | // MultiReporter is an implementation of the Reporter interface that reports the 6 | // error to multiple Reporters. If any of the individual error reporters returns 7 | // an error, a MutliError will be returned. 8 | type MultiReporter []Reporter 9 | 10 | func (r MultiReporter) Report(ctx context.Context, err error) error { 11 | var errors []error 12 | 13 | for _, reporter := range r { 14 | if err2 := reporter.Report(ctx, err); err2 != nil { 15 | errors = append(errors, err2) 16 | } 17 | } 18 | 19 | if len(errors) == 0 { 20 | return nil 21 | } 22 | 23 | return &MultiError{Errors: errors} 24 | } 25 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if the given file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stdout 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/interface.go: -------------------------------------------------------------------------------- 1 | package statsd 2 | 3 | import "time" 4 | 5 | // Statsd is an interface to a StatsD client (buffered/unbuffered) 6 | type Statsd interface { 7 | CreateSocket() error 8 | Close() error 9 | Incr(stat string, count int64) error 10 | Decr(stat string, count int64) error 11 | Timing(stat string, delta int64) error 12 | PrecisionTiming(stat string, delta time.Duration) error 13 | Gauge(stat string, value int64) error 14 | GaugeDelta(stat string, value int64) error 15 | Absolute(stat string, value int64) error 16 | Total(stat string, value int64) error 17 | 18 | FGauge(stat string, value float64) error 19 | FGaugeDelta(stat string, value float64) error 20 | FAbsolute(stat string, value float64) error 21 | } 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/lstat_test.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | ) 7 | 8 | // TestLstat tests Lstat for existing and non existing files 9 | func TestLstat(t *testing.T) { 10 | file, invalid, _, dir := prepareFiles(t) 11 | defer os.RemoveAll(dir) 12 | 13 | statFile, err := Lstat(file) 14 | if err != nil { 15 | t.Fatal(err) 16 | } 17 | if statFile == nil { 18 | t.Fatal("returned empty stat for existing file") 19 | } 20 | 21 | statInvalid, err := Lstat(invalid) 22 | if err == nil { 23 | t.Fatal("did not return error for non-existing file") 24 | } 25 | if statInvalid != nil { 26 | t.Fatal("returned non-nil stat for non-existing file") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/Dockerfile: -------------------------------------------------------------------------------- 1 | # this file describes how to build tsuru python image 2 | # to run it: 3 | # 1- install docker 4 | # 2- run: $ docker build -t tsuru/python https://raw.github.com/tsuru/basebuilder/master/python/Dockerfile 5 | 6 | from base:ubuntu-quantal 7 | run apt-get install wget -y --force-yes 8 | run wget http://github.com/tsuru/basebuilder/tarball/master -O basebuilder.tar.gz --no-check-certificate 9 | run mkdir /var/lib/tsuru 10 | run tar -xvf basebuilder.tar.gz -C /var/lib/tsuru --strip 1 11 | run cp /var/lib/tsuru/python/deploy /var/lib/tsuru 12 | run cp /var/lib/tsuru/base/restart /var/lib/tsuru 13 | run cp /var/lib/tsuru/base/start /var/lib/tsuru 14 | run /var/lib/tsuru/base/install 15 | run /var/lib/tsuru/base/setup 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/stat_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fromStatT converts a syscall.Stat_t type to a system.Stat_t type 8 | func fromStatT(s *syscall.Stat_t) (*Stat_t, error) { 9 | return &Stat_t{size: s.Size, 10 | mode: s.Mode, 11 | uid: s.Uid, 12 | gid: s.Gid, 13 | rdev: s.Rdev, 14 | mtim: s.Mtim}, nil 15 | } 16 | 17 | // Stat takes a path to a file and returns 18 | // a system.Stat_t type pertaining to that file. 19 | // 20 | // Throws an error if the file does not exist 21 | func Stat(path string) (*Stat_t, error) { 22 | s := &syscall.Stat_t{} 23 | if err := syscall.Stat(path, s); err != nil { 24 | return nil, err 25 | } 26 | return fromStatT(s) 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/mknod.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package system 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // Mknod creates a filesystem node (file, device special file or named pipe) named path 10 | // with attributes specified by mode and dev 11 | func Mknod(path string, mode uint32, dev int) error { 12 | return syscall.Mknod(path, mode, dev) 13 | } 14 | 15 | // Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes. 16 | // They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major, 17 | // then the top 12 bits of the minor 18 | func Mkdev(major int64, minor int64) uint32 { 19 | return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff)) 20 | } 21 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/fallback_test.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | func TestFallback(t *testing.T) { 11 | var called bool 12 | 13 | errTimeout := errors.New("net: timeout") 14 | 15 | r := &FallbackReporter{ 16 | Reporter: ReporterFunc(func(ctx context.Context, err error) error { 17 | return errTimeout 18 | }), 19 | Fallback: ReporterFunc(func(ctx context.Context, err error) error { 20 | called = true 21 | 22 | if got, want := err, errTimeout; got != want { 23 | t.Fatalf("err => %v; want %v", got, want) 24 | } 25 | 26 | return nil 27 | }), 28 | } 29 | 30 | r.Report(context.Background(), errBoom) 31 | 32 | if !called { 33 | t.Fatal("fallback not called") 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package context_test 6 | 7 | import ( 8 | "fmt" 9 | "time" 10 | 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | func ExampleWithTimeout() { 15 | // Pass a context with a timeout to tell a blocking function that it 16 | // should abandon its work after the timeout elapses. 17 | ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond) 18 | select { 19 | case <-time.After(200 * time.Millisecond): 20 | fmt.Println("overslept") 21 | case <-ctx.Done(): 22 | fmt.Println(ctx.Err()) // prints "context deadline exceeded" 23 | } 24 | // Output: 25 | // context deadline exceeded 26 | } 27 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if the given file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stdout 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/change_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestChangeString(t *testing.T) { 12 | var tests = []struct { 13 | change Change 14 | expected string 15 | }{ 16 | {Change{"/etc/passwd", ChangeModify}, "C /etc/passwd"}, 17 | {Change{"/etc/passwd", ChangeAdd}, "A /etc/passwd"}, 18 | {Change{"/etc/passwd", ChangeDelete}, "D /etc/passwd"}, 19 | {Change{"/etc/passwd", 33}, " /etc/passwd"}, 20 | } 21 | for _, tt := range tests { 22 | if got := tt.change.String(); got != tt.expected { 23 | t.Errorf("Change.String(): want %q. Got %q.", tt.expected, got) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /stat.go: -------------------------------------------------------------------------------- 1 | package stats 2 | 3 | // stat represents a single stat and is provided as the context to a 4 | import ( 5 | "os" 6 | "strings" 7 | 8 | "github.com/fsouza/go-dockerclient" 9 | ) 10 | 11 | var hostname string 12 | 13 | func init() { 14 | hostname, _ = os.Hostname() 15 | } 16 | 17 | // template. 18 | type stat struct { 19 | Container *docker.Container 20 | Type string 21 | Name string 22 | Value interface{} 23 | } 24 | 25 | func (s stat) Hostname() string { 26 | return hostname 27 | } 28 | 29 | // Returns the first 12 characters of the container ID. 30 | func (s stat) ID() string { 31 | return s.Container.ID[:12] 32 | } 33 | 34 | func (s stat) Env(key string) string { 35 | for _, env := range s.Container.Config.Env { 36 | if strings.HasPrefix(env, key+"=") { 37 | return env[len(key)+1:] 38 | } 39 | } 40 | return "" 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/utimes_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | func LUtimesNano(path string, ts []syscall.Timespec) error { 9 | // These are not currently available in syscall 10 | AT_FDCWD := -100 11 | AT_SYMLINK_NOFOLLOW := 0x100 12 | 13 | var _path *byte 14 | _path, err := syscall.BytePtrFromString(path) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | if _, _, err := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(AT_FDCWD), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), uintptr(AT_SYMLINK_NOFOLLOW), 0, 0); err != 0 && err != syscall.ENOSYS { 20 | return err 21 | } 22 | 23 | return nil 24 | } 25 | 26 | func UtimesNano(path string, ts []syscall.Timespec) error { 27 | return syscall.UtimesNano(path, ts) 28 | } 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/stat_test.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "os" 5 | "syscall" 6 | "testing" 7 | ) 8 | 9 | // TestFromStatT tests fromStatT for a tempfile 10 | func TestFromStatT(t *testing.T) { 11 | file, _, _, dir := prepareFiles(t) 12 | defer os.RemoveAll(dir) 13 | 14 | stat := &syscall.Stat_t{} 15 | err := syscall.Lstat(file, stat) 16 | 17 | s, err := fromStatT(stat) 18 | if err != nil { 19 | t.Fatal(err) 20 | } 21 | 22 | if stat.Mode != s.Mode() { 23 | t.Fatal("got invalid mode") 24 | } 25 | if stat.Uid != s.Uid() { 26 | t.Fatal("got invalid uid") 27 | } 28 | if stat.Gid != s.Gid() { 29 | t.Fatal("got invalid gid") 30 | } 31 | if stat.Rdev != s.Rdev() { 32 | t.Fatal("got invalid rdev") 33 | } 34 | if stat.Mtim != s.Mtim() { 35 | t.Fatal("got invalid mtim") 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/bin/fmtpolice: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | readonly GOPATH="${GOPATH%%:*}" 4 | 5 | main() { 6 | check_fmt 7 | check_lint 8 | } 9 | 10 | check_fmt() { 11 | eval "set -e" 12 | for file in $(_list_go_files) ; do 13 | gofmt $file | diff -u $file - 14 | done 15 | eval "set +e" 16 | } 17 | 18 | check_lint() { 19 | _install_linter 20 | 21 | for file in $(_list_go_files) ; do 22 | if [[ ! "$(${GOPATH}/bin/golint $file)" =~ ^[[:blank:]]*$ ]] ; then 23 | _lint_verbose && exit 1 24 | fi 25 | done 26 | } 27 | 28 | _lint_verbose() { 29 | for file in $(_list_go_files) ; do $GOPATH/bin/golint $file ; done 30 | } 31 | 32 | _install_linter() { 33 | if [[ ! -x "${GOPATH}/bin/golint" ]] ; then 34 | go get -u -f github.com/golang/lint/golint 35 | fi 36 | } 37 | 38 | _list_go_files() { 39 | git ls-files '*.go' | grep -v '^vendor/' 40 | } 41 | 42 | main "$@" 43 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/stat.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // Stat_t type contains status of a file. It contains metadata 8 | // like permission, owner, group, size, etc about a file 9 | type Stat_t struct { 10 | mode uint32 11 | uid uint32 12 | gid uint32 13 | rdev uint64 14 | size int64 15 | mtim syscall.Timespec 16 | } 17 | 18 | func (s Stat_t) Mode() uint32 { 19 | return s.mode 20 | } 21 | 22 | func (s Stat_t) Uid() uint32 { 23 | return s.uid 24 | } 25 | 26 | func (s Stat_t) Gid() uint32 { 27 | return s.gid 28 | } 29 | 30 | func (s Stat_t) Rdev() uint64 { 31 | return s.rdev 32 | } 33 | 34 | func (s Stat_t) Size() int64 { 35 | return s.size 36 | } 37 | 38 | func (s Stat_t) Mtim() syscall.Timespec { 39 | return s.mtim 40 | } 41 | 42 | func (s Stat_t) GetLastModification() syscall.Timespec { 43 | return s.Mtim() 44 | } 45 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/test-fixtures/boom-request.json: -------------------------------------------------------------------------------- 1 | { 2 | "notifier": { 3 | "name": "Honeybadger (Go)", 4 | "url": "https://github.com/remind101/pkg/reporter/hb", 5 | "version": "0.1", 6 | "language": "Go" 7 | }, 8 | "error": { 9 | "class": "*errors.errorString", 10 | "message": "boom", 11 | "backtrace": [], 12 | "source": {}, 13 | "tags": null 14 | }, 15 | "request": { 16 | "url": "/api/foo", 17 | "component": "", 18 | "action": "", 19 | "params": {}, 20 | "session": {}, 21 | "cgi_data": { 22 | "HTTP_CONTENT_TYPE": [ 23 | "application/json" 24 | ], 25 | "HTTP_X_FORWARDED_FOR": [ 26 | "127.0.0.1" 27 | ], 28 | "REQUEST_METHOD": "GET" 29 | }, 30 | "context": { 31 | "request_id": "1234" 32 | } 33 | }, 34 | "server": { 35 | "project_root": {}, 36 | "environment_name": "", 37 | "hostname": "" 38 | } 39 | } -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/logger.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/remind101/pkg/logger" 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | // LogReporter is a Handler that logs the error to a log.Logger. 11 | type LogReporter struct{} 12 | 13 | func NewLogReporter() *LogReporter { 14 | return &LogReporter{} 15 | } 16 | 17 | // Report logs the error to the Logger. 18 | func (h *LogReporter) Report(ctx context.Context, err error) error { 19 | switch err := err.(type) { 20 | case *Error: 21 | var line *BacktraceLine 22 | 23 | if len(err.Backtrace) > 0 { 24 | line = err.Backtrace[0] 25 | } else { 26 | line = &BacktraceLine{ 27 | File: "unknown", 28 | Line: 0, 29 | } 30 | } 31 | 32 | logger.Error(ctx, "", "error", fmt.Sprintf(`"%v"`, err), "line", line.Line, "file", line.File) 33 | default: 34 | logger.Error(ctx, "", "error", fmt.Sprintf(`"%v"`, err)) 35 | } 36 | 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/logger/logger_test.go: -------------------------------------------------------------------------------- 1 | package logger 2 | 3 | import ( 4 | "bytes" 5 | "log" 6 | "testing" 7 | ) 8 | 9 | func TestLogger(t *testing.T) { 10 | msg := "message" 11 | 12 | tests := []struct { 13 | in []interface{} 14 | out string 15 | }{ 16 | {[]interface{}{"key", "value"}, "message key=value\n"}, 17 | {[]interface{}{"this is a message"}, "message this is a message\n"}, 18 | {[]interface{}{"key", "value", "message"}, "message key=value message\n"}, 19 | {[]interface{}{"count", 1}, "message count=1\n"}, 20 | {[]interface{}{"b", 1, "a", 1}, "message b=1 a=1\n"}, 21 | {[]interface{}{}, "message \n"}, 22 | } 23 | 24 | for _, tt := range tests { 25 | out := testInfo(msg, tt.in...) 26 | if got, want := out, tt.out; got != want { 27 | t.Fatalf("Log => %q; want %q", got, want) 28 | } 29 | } 30 | } 31 | 32 | func testInfo(msg string, pairs ...interface{}) string { 33 | b := new(bytes.Buffer) 34 | l := New(log.New(b, "", 0)) 35 | l.Info(msg, pairs...) 36 | return b.String() 37 | } 38 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/version4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | // Random returns a Random (Version 4) UUID or panics. 8 | // 9 | // The strength of the UUIDs is based on the strength of the crypto/rand 10 | // package. 11 | // 12 | // A note about uniqueness derived from from the UUID Wikipedia entry: 13 | // 14 | // Randomly generated UUIDs have 122 random bits. One's annual risk of being 15 | // hit by a meteorite is estimated to be one chance in 17 billion, that 16 | // means the probability is about 0.00000000006 (6 × 10−11), 17 | // equivalent to the odds of creating a few tens of trillions of UUIDs in a 18 | // year and having one duplicate. 19 | func NewRandom() UUID { 20 | uuid := make([]byte, 16) 21 | randomBits([]byte(uuid)) 22 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 23 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 24 | return uuid 25 | } 26 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/trace/trace_test.go: -------------------------------------------------------------------------------- 1 | package trace 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | func TestTracedContext(t *testing.T) { 11 | ctx := &tracedContext{Context: context.Background(), id: "1234", file: "pkg/main.go", line: 10, fnname: "pkg/main.main", parent: "4321"} 12 | 13 | if id, ok := ctx.Value("trace.id").(string); !ok || id != "1234" { 14 | t.Fatalf("Expected id; got %v", id) 15 | } 16 | 17 | if id, ok := ctx.Value("trace.parent").(string); !ok || id != "4321" { 18 | t.Fatalf("Expected parent; got %v", id) 19 | } 20 | 21 | if fnname, ok := ctx.Value("trace.func").(string); !ok || fnname != "pkg/main.main" { 22 | t.Fatalf("Expected func name; got %v", fnname) 23 | } 24 | 25 | if file, ok := ctx.Value("trace.file").(string); !ok || file != "pkg/main.go" { 26 | t.Fatalf("Expected file; got %v", file) 27 | } 28 | 29 | if duration, ok := ctx.Value("trace.duration").(time.Duration); !ok { 30 | t.Fatalf("Expected a duration; got %v", duration) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/logger_test.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "bytes" 5 | "log" 6 | "testing" 7 | 8 | "github.com/remind101/pkg/logger" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | func TestLogReporter(t *testing.T) { 13 | tests := []struct { 14 | err error 15 | out string 16 | }{ 17 | {errBoom, "request_id=1234 error=\"boom\"\n"}, 18 | {&Error{Err: errBoom}, "request_id=1234 error=\"boom\" line=0 file=unknown\n"}, 19 | {&Error{Err: errBoom, Backtrace: []*BacktraceLine{&BacktraceLine{File: "foo.go", Line: 1}}}, "request_id=1234 error=\"boom\" line=1 file=foo.go\n"}, 20 | } 21 | 22 | for i, tt := range tests { 23 | b := new(bytes.Buffer) 24 | l := logger.New(log.New(b, "request_id=1234 ", 0)) 25 | h := &LogReporter{} 26 | 27 | ctx := logger.WithLogger(context.Background(), l) 28 | if err := h.Report(ctx, tt.err); err != nil { 29 | t.Fatal(err) 30 | } 31 | 32 | if got, want := b.String(), tt.out; got != want { 33 | t.Fatalf("#%d: Output => %s; want %s", i, got, want) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/ioutils/writeflusher.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | "sync" 7 | ) 8 | 9 | type WriteFlusher struct { 10 | sync.Mutex 11 | w io.Writer 12 | flusher http.Flusher 13 | flushed bool 14 | } 15 | 16 | func (wf *WriteFlusher) Write(b []byte) (n int, err error) { 17 | wf.Lock() 18 | defer wf.Unlock() 19 | n, err = wf.w.Write(b) 20 | wf.flushed = true 21 | wf.flusher.Flush() 22 | return n, err 23 | } 24 | 25 | // Flush the stream immediately. 26 | func (wf *WriteFlusher) Flush() { 27 | wf.Lock() 28 | defer wf.Unlock() 29 | wf.flushed = true 30 | wf.flusher.Flush() 31 | } 32 | 33 | func (wf *WriteFlusher) Flushed() bool { 34 | wf.Lock() 35 | defer wf.Unlock() 36 | return wf.flushed 37 | } 38 | 39 | func NewWriteFlusher(w io.Writer) *WriteFlusher { 40 | var flusher http.Flusher 41 | if f, ok := w.(http.Flusher); ok { 42 | flusher = f 43 | } else { 44 | flusher = &NopFlusher{} 45 | } 46 | return &WriteFlusher{w: w, flusher: flusher} 47 | } 48 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/writer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package testing 6 | 7 | import ( 8 | "encoding/binary" 9 | "errors" 10 | "io" 11 | ) 12 | 13 | type stdType [8]byte 14 | 15 | var ( 16 | stdin = stdType{0: 0} 17 | stdout = stdType{0: 1} 18 | stderr = stdType{0: 2} 19 | ) 20 | 21 | type stdWriter struct { 22 | io.Writer 23 | prefix stdType 24 | sizeBuf []byte 25 | } 26 | 27 | func (w *stdWriter) Write(buf []byte) (n int, err error) { 28 | if w == nil || w.Writer == nil { 29 | return 0, errors.New("Writer not instanciated") 30 | } 31 | binary.BigEndian.PutUint32(w.prefix[4:], uint32(len(buf))) 32 | buf = append(w.prefix[:], buf...) 33 | 34 | n, err = w.Writer.Write(buf) 35 | return n - 8, err 36 | } 37 | 38 | func newStdWriter(w io.Writer, t stdType) *stdWriter { 39 | if len(t) != 8 { 40 | return nil 41 | } 42 | return &stdWriter{Writer: w, prefix: t, sizeBuf: make([]byte, 4)} 43 | } 44 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: \ 2 | all \ 3 | vendor \ 4 | lint \ 5 | vet \ 6 | fmt \ 7 | fmtcheck \ 8 | pretest \ 9 | test \ 10 | cov \ 11 | clean 12 | 13 | all: test 14 | 15 | vendor: 16 | go get -v github.com/mjibson/party 17 | party -d vendor -c -u 18 | 19 | lint: 20 | go get -v github.com/golang/lint/golint 21 | for file in $(shell git ls-files '*.go' | grep -v '^vendor/'); do \ 22 | golint $$file; \ 23 | done 24 | 25 | vet: 26 | go get -v golang.org/x/tools/cmd/vet 27 | go vet ./... 28 | 29 | fmt: 30 | gofmt -w $(shell git ls-files '*.go' | grep -v '^vendor/') 31 | 32 | fmtcheck: 33 | for file in $(shell git ls-files '*.go' | grep -v '^vendor/'); do \ 34 | gofmt $$file | diff -u $$file -; \ 35 | if [ -n "$$(gofmt $$file | diff -u $$file -)" ]; then\ 36 | exit 1; \ 37 | fi; \ 38 | done 39 | 40 | pretest: lint vet fmtcheck 41 | 42 | test: pretest 43 | go test 44 | go test ./testing 45 | 46 | cov: 47 | go get -v github.com/axw/gocov/gocov 48 | go get golang.org/x/tools/cmd/cover 49 | gocov test | gocov report 50 | 51 | clean: 52 | go clean ./... 53 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/units/duration.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // HumanDuration returns a human-readable approximation of a duration 9 | // (eg. "About a minute", "4 hours ago", etc.) 10 | func HumanDuration(d time.Duration) string { 11 | if seconds := int(d.Seconds()); seconds < 1 { 12 | return "Less than a second" 13 | } else if seconds < 60 { 14 | return fmt.Sprintf("%d seconds", seconds) 15 | } else if minutes := int(d.Minutes()); minutes == 1 { 16 | return "About a minute" 17 | } else if minutes < 60 { 18 | return fmt.Sprintf("%d minutes", minutes) 19 | } else if hours := int(d.Hours()); hours == 1 { 20 | return "About an hour" 21 | } else if hours < 48 { 22 | return fmt.Sprintf("%d hours", hours) 23 | } else if hours < 24*7*2 { 24 | return fmt.Sprintf("%d days", hours/24) 25 | } else if hours < 24*30*3 { 26 | return fmt.Sprintf("%d weeks", hours/24/7) 27 | } else if hours < 24*365*2 { 28 | return fmt.Sprintf("%d months", hours/24/30) 29 | } else { 30 | return fmt.Sprintf("%d years", hours/24/365) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/meminfo_linux_test.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | 7 | "github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/units" 8 | ) 9 | 10 | // TestMemInfo tests parseMemInfo with a static meminfo string 11 | func TestMemInfo(t *testing.T) { 12 | const input = ` 13 | MemTotal: 1 kB 14 | MemFree: 2 kB 15 | SwapTotal: 3 kB 16 | SwapFree: 4 kB 17 | Malformed1: 18 | Malformed2: 1 19 | Malformed3: 2 MB 20 | Malformed4: X kB 21 | ` 22 | meminfo, err := parseMemInfo(strings.NewReader(input)) 23 | if err != nil { 24 | t.Fatal(err) 25 | } 26 | if meminfo.MemTotal != 1*units.KiB { 27 | t.Fatalf("Unexpected MemTotal: %d", meminfo.MemTotal) 28 | } 29 | if meminfo.MemFree != 2*units.KiB { 30 | t.Fatalf("Unexpected MemFree: %d", meminfo.MemFree) 31 | } 32 | if meminfo.SwapTotal != 3*units.KiB { 33 | t.Fatalf("Unexpected SwapTotal: %d", meminfo.SwapTotal) 34 | } 35 | if meminfo.SwapFree != 4*units.KiB { 36 | t.Fatalf("Unexpected SwapFree: %d", meminfo.SwapFree) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC1TCCAb+gAwIBAgIQJ9MsNxrUxumNbAytGi3GEDALBgkqhkiG9w0BAQswFjEU 3 | MBIGA1UEChMLQm9vdDJEb2NrZXIwHhcNMTQxMDE2MjAyMTM4WhcNMTcwOTMwMjAy 4 | MTM4WjAWMRQwEgYDVQQKEwtCb290MkRvY2tlcjCCASIwDQYJKoZIhvcNAQEBBQAD 5 | ggEPADCCAQoCggEBALpFCSARjG+5yXoqr7UMzuE0df7RRZfeRZI06lJ02ZqV4Iii 6 | rgL7ML9yPxX50NbLnjiilSDTUhnyocYFItokzUzz8qpX/nlYhuN2Iqwh4d0aWS8z 7 | f5y248F+H1z+HY2W8NPl/6DVlVwYaNW1/k+RPMlHS0INLR6j+3Ievew7RNE0NnM2 8 | znELW6NetekDt3GUcz0Z95vDUDfdPnIk1eIFMmYvLxZh23xOca4Q37a3S8F3d+dN 9 | +OOpwjdgY9Qme0NQUaXpgp58jWuQfB8q7mZrdnLlLqRa8gx1HeDSotX7UmWtWPkb 10 | vd9EdlKLYw5PVpxMV1rkwf2t4TdgD5NfkpXlXkkCAwEAAaMjMCEwDgYDVR0PAQH/ 11 | BAQDAgCkMA8GA1UdEwEB/wQFMAMBAf8wCwYJKoZIhvcNAQELA4IBAQBxYjHVSKqE 12 | MJw7CW0GddesULtXXVWGJuZdWJLQlPvPMfIfjIvlcZyS4cdVNiQ3sREFIZz8TpII 13 | CT0/Pg3sgv/FcOQe1CN0xZYZcyiAZHK1z0fJQq2qVpdv7+tJcjI2vvU6NI24iQCo 14 | W1wz25trJz9QbdB2MRLMjyz7TSWuafztIvcfEzaIdQ0Whqund/cSuPGQx5IwF83F 15 | rvlkOyJSH2+VIEBTCIuykJeL0DLTt8cePBQR5L1ISXb4RUMK9ZtqRscBRv8sn7o2 16 | ixG3wtL0gYF4xLtsQWVxI3iFVrU3WzOH/3c5shVRkWBd+AQRSwCJI4mKH7penJCF 17 | i3/zzlkvOnjV 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | if f.TimestampFormat == "" { 28 | f.TimestampFormat = DefaultTimestampFormat 29 | } 30 | 31 | data["time"] = entry.Time.Format(f.TimestampFormat) 32 | data["msg"] = entry.Message 33 | data["level"] = entry.Level.String() 34 | 35 | serialized, err := json.Marshal(data) 36 | if err != nil { 37 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 38 | } 39 | return append(serialized, '\n'), nil 40 | } 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/change.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | import "fmt" 8 | 9 | // ChangeType is a type for constants indicating the type of change 10 | // in a container 11 | type ChangeType int 12 | 13 | const ( 14 | // ChangeModify is the ChangeType for container modifications 15 | ChangeModify ChangeType = iota 16 | 17 | // ChangeAdd is the ChangeType for additions to a container 18 | ChangeAdd 19 | 20 | // ChangeDelete is the ChangeType for deletions from a container 21 | ChangeDelete 22 | ) 23 | 24 | // Change represents a change in a container. 25 | // 26 | // See http://goo.gl/QkW9sH for more details. 27 | type Change struct { 28 | Path string 29 | Kind ChangeType 30 | } 31 | 32 | func (change *Change) String() string { 33 | var kind string 34 | switch change.Kind { 35 | case ChangeModify: 36 | kind = "C" 37 | case ChangeAdd: 38 | kind = "A" 39 | case ChangeDelete: 40 | kind = "D" 41 | } 42 | return fmt.Sprintf("%s %s", kind, change.Path) 43 | } 44 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC6DCCAdKgAwIBAgIRANO6ymxQAjp66KmEka1G6b0wCwYJKoZIhvcNAQELMBYx 3 | FDASBgNVBAoTC0Jvb3QyRG9ja2VyMB4XDTE0MTAxNjIwMjE1MloXDTE3MDkzMDIw 4 | MjE1MlowFjEUMBIGA1UEChMLQm9vdDJEb2NrZXIwggEiMA0GCSqGSIb3DQEBAQUA 5 | A4IBDwAwggEKAoIBAQDGA1mAhSOpZspD1dpZ7qVEQrIJw4Xo8252jHaORnEdDiFm 6 | b6brEmr6jw8t4P3IGxbqBc/TqRV+SSXxwYEVvfpeQKH+SmqStoMNtD3Ura161az4 7 | V0BcxMtSlsUGpoz+//QCAq8qiaxMwgiyc5253mkQm88anj2cNt7xbewiu/KFWuf7 8 | BVpNK1+ltpJmlukfcj/G+I1bw7j1KxBjDrFqe5cyDuuZcDL2tmUXP/ZWDyXwSv+H 9 | AOckqn44z6aXlBkVvOXDBZJqY76d/vWVDNCuZeXRnqlhP3t1kH4V0RQXo+JD2tgt 10 | JgdU0unzyoFOSWNUBPm73tqmjUGGAmGHBmeegJr/AgMBAAGjNTAzMA4GA1UdDwEB 11 | /wQEAwIAgDATBgNVHSUEDDAKBggrBgEFBQcDAjAMBgNVHRMBAf8EAjAAMAsGCSqG 12 | SIb3DQEBCwOCAQEABVTWl5SmBP+j5He5bQsgnIXjviSKqe40/10V4LJAOmilycRF 13 | zLrzM+YMwfjg6PLIs8CldAMWHw9y9ktZY4MxkgCktaiaN/QmMTMwFWEcN4wy5IpM 14 | U5l93eAg7xsnY430h3QBBADujX4wdF3fs8rSL8zAAQFL0ihurwU124K3yXKsrwpb 15 | CiVUGfIN4sPwjy8Ws9oxHFDC9/P8lgjHZ1nBIf8KSHnMzlxDGj7isQfhtH+7mcCL 16 | cM1qO2NirS2v7uaEPPY+MJstAz+W7EJCW9dfMSmHna2SDC37Xkin7uEY9z+qaKFL 17 | 8d/XxOB/L8Ucy8VZhdsv0dsBq5KfJntITM0ksQ== 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Lorenzo Alberton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2013 Jeremy Saenz 2 | All Rights Reserved. 3 | 4 | MIT LICENSE 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/server.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIC/DCCAeagAwIBAgIQMUILcXtvmSOK63zEBo0VXzALBgkqhkiG9w0BAQswFjEU 3 | MBIGA1UEChMLQm9vdDJEb2NrZXIwHhcNMTQxMDE2MjAyMTQ2WhcNMTcwOTMwMjAy 4 | MTQ2WjAWMRQwEgYDVQQKEwtCb290MkRvY2tlcjCCASIwDQYJKoZIhvcNAQEBBQAD 5 | ggEPADCCAQoCggEBANxUOUhNnqFnrTlLsBYzfFRZWQo268l+4K4lOJCVbfDonP3g 6 | Mz0vGi9fcyFqEWSA8Y+ShXna625HTnReCwFdsu0861qCIq7v95hFFCyOe0iIxpd0 7 | AKLnl90d+1vonE7andgFgoobbTiMly4UK4H6z8D148fFNIihoteOG3PIF89TFxP7 8 | CJ/3wXnx/IKpdlO8PAnub3tBPJHvGDj7KORLy4IBxRX5VBAdfGNybE66fcrehEva 9 | rLA4m9pgiaR/Nnr9FdKhPyqYdjflLNvzydxNvMIV4M0hFlhXmYvpMjA5/XsTnsyV 10 | t9JHJa5Upwqsbne08t7rsm7liZNxZlko8xPOTQcCAwEAAaNKMEgwDgYDVR0PAQH/ 11 | BAQDAgCgMAwGA1UdEwEB/wQCMAAwKAYDVR0RBCEwH4ILYm9vdDJkb2NrZXKHBH8A 12 | AAGHBAoAAg+HBMCoO2cwCwYJKoZIhvcNAQELA4IBAQAYoYcDkDWkl73FZ0WnPmAj 13 | LiF7HU95Qg3KyEpFsAJeShSLPPbQntmwhdekEzY4tQ3eKQB/+zHFjzsCr/lmDUmH 14 | Ea/ryQ17C+jyH+Ykg0IWW6L6veZhvRDg6Z9focVtPVBRxPTqC/Qhb54blWRASV+W 15 | UreMuXQ5+1dQptAM7ixOeLVHjBi/bd9TL3jvwBVCr9QedteMjjK4TCF9Tbcou+MF 16 | 2w3OJJZMDhcD+YwoK9uJDqlKmcTm/vVMbSsp/pTMcnQ7jxCeR8/XyX+VwTZwaHAa 17 | o92Q/eg3THAiWhvyT/SzyH9dHHBAyXynUwGCggKawHktfvW4QXRPuLxLrJ7iB5cy 18 | -----END CERTIFICATE----- 19 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/command_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | 7 | "github.com/codegangsta/cli" 8 | ) 9 | 10 | func TestCommandDoNotIgnoreFlags(t *testing.T) { 11 | app := cli.NewApp() 12 | set := flag.NewFlagSet("test", 0) 13 | test := []string{"blah", "blah", "-break"} 14 | set.Parse(test) 15 | 16 | c := cli.NewContext(app, set, set) 17 | 18 | command := cli.Command{ 19 | Name: "test-cmd", 20 | ShortName: "tc", 21 | Usage: "this is for testing", 22 | Description: "testing", 23 | Action: func(_ *cli.Context) {}, 24 | } 25 | err := command.Run(c) 26 | 27 | expect(t, err.Error(), "flag provided but not defined: -break") 28 | } 29 | 30 | func TestCommandIgnoreFlags(t *testing.T) { 31 | app := cli.NewApp() 32 | set := flag.NewFlagSet("test", 0) 33 | test := []string{"blah", "blah"} 34 | set.Parse(test) 35 | 36 | c := cli.NewContext(app, set, set) 37 | 38 | command := cli.Command{ 39 | Name: "test-cmd", 40 | ShortName: "tc", 41 | Usage: "this is for testing", 42 | Description: "testing", 43 | Action: func(_ *cli.Context) {}, 44 | SkipFlagParsing: true, 45 | } 46 | err := command.Run(c) 47 | 48 | expect(t, err, nil) 49 | } 50 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/nr/nr.go: -------------------------------------------------------------------------------- 1 | package nr 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | 7 | "github.com/remind101/newrelic" 8 | "github.com/remind101/pkg/reporter" 9 | "github.com/remind101/pkg/reporter/util" 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | // Ensure that Reporter implements the reporter.Reporter interface. 14 | var _ reporter.Reporter = &Reporter{} 15 | 16 | type Reporter struct{} 17 | 18 | func NewReporter() *Reporter { 19 | return &Reporter{} 20 | } 21 | 22 | func (r *Reporter) Report(ctx context.Context, err error) error { 23 | if tx, ok := newrelic.FromContext(ctx); ok { 24 | var ( 25 | exceptionType string 26 | errorMessage string 27 | stackTrace []string 28 | stackFrameDelim string 29 | ) 30 | 31 | errorMessage = err.Error() 32 | stackFrameDelim = "\n" 33 | stackTrace = make([]string, 0) 34 | 35 | if e, ok := err.(*reporter.Error); ok { 36 | exceptionType = util.ClassName(e.Err) 37 | 38 | for _, l := range e.Backtrace { 39 | stackTrace = append(stackTrace, fmt.Sprintf("%s:%d %s", l.File, l.Line, util.FunctionName(l.PC))) 40 | } 41 | 42 | } 43 | 44 | return tx.ReportError(exceptionType, errorMessage, strings.Join(stackTrace, stackFrameDelim), stackFrameDelim) 45 | } 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type levelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks levelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks levelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/version1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | ) 10 | 11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock 12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID 13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot 14 | // be set NewUUID returns nil. If clock sequence has not been set by 15 | // SetClockSequence then it will be set automatically. If GetTime fails to 16 | // return the current NewUUID returns nil. 17 | func NewUUID() UUID { 18 | if nodeID == nil { 19 | SetNodeInterface("") 20 | } 21 | 22 | now, err := GetTime() 23 | if err != nil { 24 | return nil 25 | } 26 | 27 | uuid := make([]byte, 16) 28 | 29 | time_low := uint32(now & 0xffffffff) 30 | time_mid := uint16((now >> 32) & 0xffff) 31 | time_hi := uint16((now >> 48) & 0x0fff) 32 | time_hi |= 0x1000 // Version 1 33 | 34 | binary.BigEndian.PutUint32(uuid[0:], time_low) 35 | binary.BigEndian.PutUint16(uuid[4:], time_mid) 36 | binary.BigEndian.PutUint16(uuid[6:], time_hi) 37 | binary.BigEndian.PutUint16(uuid[8:], clock_seq) 38 | copy(uuid[10:], nodeID) 39 | 40 | return uuid 41 | } 42 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/entry_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "testing" 7 | 8 | "github.com/fsouza/go-dockerclient/vendor/github.com/stretchr/testify/assert" 9 | ) 10 | 11 | func TestEntryPanicln(t *testing.T) { 12 | errBoom := fmt.Errorf("boom time") 13 | 14 | defer func() { 15 | p := recover() 16 | assert.NotNil(t, p) 17 | 18 | switch pVal := p.(type) { 19 | case *Entry: 20 | assert.Equal(t, "kaboom", pVal.Message) 21 | assert.Equal(t, errBoom, pVal.Data["err"]) 22 | default: 23 | t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) 24 | } 25 | }() 26 | 27 | logger := New() 28 | logger.Out = &bytes.Buffer{} 29 | entry := NewEntry(logger) 30 | entry.WithField("err", errBoom).Panicln("kaboom") 31 | } 32 | 33 | func TestEntryPanicf(t *testing.T) { 34 | errBoom := fmt.Errorf("boom again") 35 | 36 | defer func() { 37 | p := recover() 38 | assert.NotNil(t, p) 39 | 40 | switch pVal := p.(type) { 41 | case *Entry: 42 | assert.Equal(t, "kaboom true", pVal.Message) 43 | assert.Equal(t, errBoom, pVal.Data["err"]) 44 | default: 45 | t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal) 46 | } 47 | }() 48 | 49 | logger := New() 50 | logger.Out = &bytes.Buffer{} 51 | entry := NewEntry(logger) 52 | entry.WithField("err", errBoom).Panicf("kaboom %v", true) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, go-dockerclient authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/archive_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package archive 4 | 5 | import ( 6 | "archive/tar" 7 | "fmt" 8 | "os" 9 | "strings" 10 | ) 11 | 12 | // canonicalTarNameForPath returns platform-specific filepath 13 | // to canonical posix-style path for tar archival. p is relative 14 | // path. 15 | func CanonicalTarNameForPath(p string) (string, error) { 16 | // windows: convert windows style relative path with backslashes 17 | // into forward slashes. since windows does not allow '/' or '\' 18 | // in file names, it is mostly safe to replace however we must 19 | // check just in case 20 | if strings.Contains(p, "/") { 21 | return "", fmt.Errorf("windows path contains forward slash: %s", p) 22 | } 23 | return strings.Replace(p, string(os.PathSeparator), "/", -1), nil 24 | 25 | } 26 | 27 | // chmodTarEntry is used to adjust the file permissions used in tar header based 28 | // on the platform the archival is done. 29 | func chmodTarEntry(perm os.FileMode) os.FileMode { 30 | perm &= 0755 31 | // Add the x bit: make everything +x from windows 32 | perm |= 0111 33 | 34 | return perm 35 | } 36 | 37 | func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) { 38 | // do nothing. no notion of Rdev, Inode, Nlink in stat on Windows 39 | return 40 | } 41 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/multi_test.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | 7 | "golang.org/x/net/context" 8 | ) 9 | 10 | func TestMultiReporter(t *testing.T) { 11 | var ( 12 | r1Called bool 13 | r2Called bool 14 | ) 15 | 16 | r1 := ReporterFunc(func(ctx context.Context, err error) error { 17 | r1Called = true 18 | return nil 19 | }) 20 | 21 | r2 := ReporterFunc(func(ctx context.Context, err error) error { 22 | r2Called = true 23 | return nil 24 | }) 25 | 26 | h := MultiReporter{r1, r2} 27 | 28 | if err := h.Report(context.Background(), errBoom); err != nil { 29 | t.Fatal(err) 30 | } 31 | 32 | if got, want := r1Called, true; got != want { 33 | t.Fatal("Expected r1 to be called") 34 | } 35 | 36 | if got, want := r2Called, true; got != want { 37 | t.Fatal("Expected r2 to be called") 38 | } 39 | } 40 | 41 | // Tests when the Report method of the individual reporters returns an error. 42 | func TestMultiReporterError(t *testing.T) { 43 | r1 := ReporterFunc(func(ctx context.Context, err error) error { 44 | return errors.New("boom 1") 45 | }) 46 | 47 | r2 := ReporterFunc(func(ctx context.Context, err error) error { 48 | return errors.New("boom 2") 49 | }) 50 | 51 | h := MultiReporter{r1, r2} 52 | 53 | err := h.Report(context.Background(), errBoom) 54 | 55 | if _, ok := err.(*MultiError); !ok { 56 | t.Fatal("Expected a MultiError to be returned") 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/ioutils/writers.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import "io" 4 | 5 | type NopWriter struct{} 6 | 7 | func (*NopWriter) Write(buf []byte) (int, error) { 8 | return len(buf), nil 9 | } 10 | 11 | type nopWriteCloser struct { 12 | io.Writer 13 | } 14 | 15 | func (w *nopWriteCloser) Close() error { return nil } 16 | 17 | func NopWriteCloser(w io.Writer) io.WriteCloser { 18 | return &nopWriteCloser{w} 19 | } 20 | 21 | type NopFlusher struct{} 22 | 23 | func (f *NopFlusher) Flush() {} 24 | 25 | type writeCloserWrapper struct { 26 | io.Writer 27 | closer func() error 28 | } 29 | 30 | func (r *writeCloserWrapper) Close() error { 31 | return r.closer() 32 | } 33 | 34 | func NewWriteCloserWrapper(r io.Writer, closer func() error) io.WriteCloser { 35 | return &writeCloserWrapper{ 36 | Writer: r, 37 | closer: closer, 38 | } 39 | } 40 | 41 | // Wrap a concrete io.Writer and hold a count of the number 42 | // of bytes written to the writer during a "session". 43 | // This can be convenient when write return is masked 44 | // (e.g., json.Encoder.Encode()) 45 | type WriteCounter struct { 46 | Count int64 47 | Writer io.Writer 48 | } 49 | 50 | func NewWriteCounter(w io.Writer) *WriteCounter { 51 | return &WriteCounter{ 52 | Writer: w, 53 | } 54 | } 55 | 56 | func (wc *WriteCounter) Write(p []byte) (count int, err error) { 57 | count, err = wc.Writer.Write(p) 58 | wc.Count += int64(count) 59 | return 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/nr/nr_test.go: -------------------------------------------------------------------------------- 1 | package nr 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | 7 | "github.com/remind101/newrelic" 8 | "github.com/remind101/pkg/reporter" 9 | "golang.org/x/net/context" 10 | ) 11 | 12 | var ( 13 | // boom 14 | errBoom = errors.New("boom") 15 | 16 | // boom with backtrace. 17 | errBoomMore = reporter.NewError(errBoom, 0) 18 | ) 19 | 20 | func TestReport(t *testing.T) { 21 | tx := newrelic.NewTx("GET /boom") 22 | tx.Reporter = &TestReporter{ 23 | f: func(id int64, exceptionType, errorMessage, stackTrace, stackFrameDelim string) { 24 | if got, want := exceptionType, "*errors.errorString"; got != want { 25 | t.Errorf("exceptionType => %v; want %v", got, want) 26 | } 27 | if got, want := errorMessage, "boom"; got != want { 28 | t.Errorf("errorMessage => %v; want %v", got, want) 29 | } 30 | 31 | if stackTrace == "" { 32 | t.Error("stackTrace: expected to not be empty") 33 | } 34 | }, 35 | } 36 | 37 | ctx := context.Background() 38 | ctx = newrelic.WithTx(ctx, tx) 39 | 40 | r := NewReporter() 41 | r.Report(ctx, errBoomMore) 42 | } 43 | 44 | type TestReporter struct { 45 | f func(id int64, exceptionType, errorMessage, stackTrace, stackFrameDelim string) 46 | } 47 | 48 | func (r *TestReporter) ReportError(id int64, exceptionType, errorMessage, stackTrace, stackFrameDelim string) (int, error) { 49 | r.f(id, exceptionType, errorMessage, stackTrace, stackFrameDelim) 50 | return 0, nil 51 | } 52 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/auth_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | import ( 8 | "encoding/base64" 9 | "fmt" 10 | "strings" 11 | "testing" 12 | ) 13 | 14 | func TestAuthConfig(t *testing.T) { 15 | auth := base64.StdEncoding.EncodeToString([]byte("user:pass")) 16 | read := strings.NewReader(fmt.Sprintf(`{"docker.io":{"auth":"%s","email":"user@example.com"}}`, auth)) 17 | ac, err := NewAuthConfigurations(read) 18 | if err != nil { 19 | t.Error(err) 20 | } 21 | c, ok := ac.Configs["docker.io"] 22 | if !ok { 23 | t.Error("NewAuthConfigurations: Expected Configs to contain docker.io") 24 | } 25 | if got, want := c.Email, "user@example.com"; got != want { 26 | t.Errorf(`AuthConfigurations.Configs["docker.io"].Email: wrong result. Want %q. Got %q`, want, got) 27 | } 28 | if got, want := c.Username, "user"; got != want { 29 | t.Errorf(`AuthConfigurations.Configs["docker.io"].Username: wrong result. Want %q. Got %q`, want, got) 30 | } 31 | if got, want := c.Password, "pass"; got != want { 32 | t.Errorf(`AuthConfigurations.Configs["docker.io"].Password: wrong result. Want %q. Got %q`, want, got) 33 | } 34 | if got, want := c.ServerAddress, "docker.io"; got != want { 35 | t.Errorf(`AuthConfigurations.Configs["docker.io"].ServerAddress: wrong result. Want %q. Got %q`, want, got) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/test-fixtures/boom-more.json: -------------------------------------------------------------------------------- 1 | { 2 | "notifier": { 3 | "name": "Honeybadger (Go)", 4 | "url": "https://github.com/remind101/pkg/reporter/hb", 5 | "version": "0.1", 6 | "language": "Go" 7 | }, 8 | "error": { 9 | "class": "*errors.errorString", 10 | "message": "boom", 11 | "backtrace": [ 12 | { 13 | "method": "github.com/remind101/pkg/reporter/hb.init", 14 | "file": "(removed)/hb_test.go", 15 | "number": "(removed)" 16 | }, 17 | { 18 | "method": "github.com/remind101/pkg/reporter/hb_test.init", 19 | "file": "(removed)/example_test.go", 20 | "number": "(removed)" 21 | }, 22 | { 23 | "method": "main.init", 24 | "file": "(removed)/_testmain.go", 25 | "number": "(removed)" 26 | }, 27 | { 28 | "method": "runtime.main", 29 | "file": "(removed)/proc.go", 30 | "number": "(removed)" 31 | }, 32 | { 33 | "method": "runtime.goexit", 34 | "file": "(removed)/asm_amd64.s", 35 | "number": "(removed)" 36 | } 37 | ], 38 | "source": {}, 39 | "tags": null 40 | }, 41 | "request": { 42 | "url": "", 43 | "component": "", 44 | "action": "", 45 | "params": {}, 46 | "session": {}, 47 | "cgi_data": {}, 48 | "context": {} 49 | }, 50 | "server": { 51 | "project_root": {}, 52 | "environment_name": "", 53 | "hostname": "" 54 | } 55 | } -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/signal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | // Signal represents a signal that can be send to the container on 8 | // KillContainer call. 9 | type Signal int 10 | 11 | // These values represent all signals available on Linux, where containers will 12 | // be running. 13 | const ( 14 | SIGABRT = Signal(0x6) 15 | SIGALRM = Signal(0xe) 16 | SIGBUS = Signal(0x7) 17 | SIGCHLD = Signal(0x11) 18 | SIGCLD = Signal(0x11) 19 | SIGCONT = Signal(0x12) 20 | SIGFPE = Signal(0x8) 21 | SIGHUP = Signal(0x1) 22 | SIGILL = Signal(0x4) 23 | SIGINT = Signal(0x2) 24 | SIGIO = Signal(0x1d) 25 | SIGIOT = Signal(0x6) 26 | SIGKILL = Signal(0x9) 27 | SIGPIPE = Signal(0xd) 28 | SIGPOLL = Signal(0x1d) 29 | SIGPROF = Signal(0x1b) 30 | SIGPWR = Signal(0x1e) 31 | SIGQUIT = Signal(0x3) 32 | SIGSEGV = Signal(0xb) 33 | SIGSTKFLT = Signal(0x10) 34 | SIGSTOP = Signal(0x13) 35 | SIGSYS = Signal(0x1f) 36 | SIGTERM = Signal(0xf) 37 | SIGTRAP = Signal(0x5) 38 | SIGTSTP = Signal(0x14) 39 | SIGTTIN = Signal(0x15) 40 | SIGTTOU = Signal(0x16) 41 | SIGUNUSED = Signal(0x1f) 42 | SIGURG = Signal(0x17) 43 | SIGUSR1 = Signal(0xa) 44 | SIGUSR2 = Signal(0xc) 45 | SIGVTALRM = Signal(0x1a) 46 | SIGWINCH = Signal(0x1c) 47 | SIGXCPU = Signal(0x18) 48 | SIGXFSZ = Signal(0x19) 49 | ) 50 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/remind101/dockerstats", 3 | "GoVersion": "go1.4.2", 4 | "Packages": [ 5 | "./..." 6 | ], 7 | "Deps": [ 8 | { 9 | "ImportPath": "code.google.com/p/go-uuid/uuid", 10 | "Comment": "null-12", 11 | "Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9" 12 | }, 13 | { 14 | "ImportPath": "github.com/codegangsta/cli", 15 | "Comment": "1.2.0-26-gf7ebb76", 16 | "Rev": "f7ebb761e83e21225d1d8954fde853bf8edd46c4" 17 | }, 18 | { 19 | "ImportPath": "github.com/fsouza/go-dockerclient", 20 | "Rev": "b0f4fa94c14794e30cf3b9176e5dc4725d9552ed" 21 | }, 22 | { 23 | "ImportPath": "github.com/mb0/glob", 24 | "Rev": "4312440cf66256264db33209a01e637873017f2b" 25 | }, 26 | { 27 | "ImportPath": "github.com/quipo/statsd", 28 | "Rev": "b16c3be8a03e3c39a2d9c669b8f13f8876de61cd" 29 | }, 30 | { 31 | "ImportPath": "github.com/remind101/empire/pkg/dockerutil", 32 | "Comment": "v0.9.0-137-g88b09a4", 33 | "Rev": "88b09a48f32fe8c990b8a922b4c3aaeb1fd013ad" 34 | }, 35 | { 36 | "ImportPath": "github.com/remind101/pkg/logger", 37 | "Rev": "835283e5cf4be4a19295819879cc5259718ec075" 38 | }, 39 | { 40 | "ImportPath": "github.com/remind101/pkg/reporter", 41 | "Rev": "835283e5cf4be4a19295819879cc5259718ec075" 42 | }, 43 | { 44 | "ImportPath": "github.com/remind101/pkg/trace", 45 | "Rev": "835283e5cf4be4a19295819879cc5259718ec075" 46 | }, 47 | { 48 | "ImportPath": "golang.org/x/net/context", 49 | "Rev": "1dfe7915deaf3f80b962c163b918868d8a6d8974" 50 | } 51 | ] 52 | } 53 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/reporter_test.go: -------------------------------------------------------------------------------- 1 | package reporter 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | "path" 7 | "runtime" 8 | "testing" 9 | 10 | "golang.org/x/net/context" 11 | ) 12 | 13 | var errBoom = errors.New("boom") 14 | 15 | func TestReport(t *testing.T) { 16 | r := ReporterFunc(func(ctx context.Context, err error) error { 17 | e := err.(*Error) 18 | 19 | if e.Request.Header.Get("Content-Type") != "application/json" { 20 | t.Fatal("request information not set") 21 | } 22 | 23 | checkFirstFunc(t, e, "reporter.TestReport") 24 | 25 | return nil 26 | }) 27 | ctx := WithReporter(context.Background(), r) 28 | 29 | req, _ := http.NewRequest("GET", "/", nil) 30 | req.Header.Set("Content-Type", "application/json") 31 | AddRequest(ctx, req) 32 | 33 | if err := Report(ctx, errBoom); err != nil { 34 | t.Fatal(err) 35 | } 36 | } 37 | 38 | func TestReportWithSkip(t *testing.T) { 39 | r := ReporterFunc(func(ctx context.Context, err error) error { 40 | e := err.(*Error) 41 | 42 | checkFirstFunc(t, e, "reporter.TestReportWithSkip") 43 | 44 | return nil 45 | }) 46 | ctx := WithReporter(context.Background(), r) 47 | 48 | func() { 49 | if err := ReportWithSkip(ctx, errBoom, 1); err != nil { 50 | t.Fatal(err) 51 | } 52 | }() 53 | } 54 | 55 | func checkFirstFunc(t testing.TB, err *Error, name string) { 56 | line := err.Backtrace[0] 57 | fn := runtime.FuncForPC(line.PC) 58 | 59 | if got, want := path.Base(fn.Name()), name; got != want { 60 | t.Fatalf("Function => %s; want %s", got, want) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/archive_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package archive 4 | 5 | import ( 6 | "archive/tar" 7 | "errors" 8 | "os" 9 | "syscall" 10 | ) 11 | 12 | // canonicalTarNameForPath returns platform-specific filepath 13 | // to canonical posix-style path for tar archival. p is relative 14 | // path. 15 | func CanonicalTarNameForPath(p string) (string, error) { 16 | return p, nil // already unix-style 17 | } 18 | 19 | // chmodTarEntry is used to adjust the file permissions used in tar header based 20 | // on the platform the archival is done. 21 | 22 | func chmodTarEntry(perm os.FileMode) os.FileMode { 23 | return perm // noop for unix as golang APIs provide perm bits correctly 24 | } 25 | 26 | func setHeaderForSpecialDevice(hdr *tar.Header, ta *tarAppender, name string, stat interface{}) (nlink uint32, inode uint64, err error) { 27 | s, ok := stat.(*syscall.Stat_t) 28 | 29 | if !ok { 30 | err = errors.New("cannot convert stat value to syscall.Stat_t") 31 | return 32 | } 33 | 34 | nlink = uint32(s.Nlink) 35 | inode = uint64(s.Ino) 36 | 37 | // Currently go does not fil in the major/minors 38 | if s.Mode&syscall.S_IFBLK != 0 || 39 | s.Mode&syscall.S_IFCHR != 0 { 40 | hdr.Devmajor = int64(major(uint64(s.Rdev))) 41 | hdr.Devminor = int64(minor(uint64(s.Rdev))) 42 | } 43 | 44 | return 45 | } 46 | 47 | func major(device uint64) uint64 { 48 | return (device >> 8) & 0xfff 49 | } 50 | 51 | func minor(device uint64) uint64 { 52 | return (device & 0xff) | ((device >> 12) & 0xfff00) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/total.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // Total represents a metric that is continously increasing, e.g. read operations since boot 6 | type Total struct { 7 | Name string 8 | Value int64 9 | } 10 | 11 | // Update the event with metrics coming from a new one of the same type and with the same key 12 | func (e *Total) Update(e2 Event) error { 13 | if e.Type() != e2.Type() { 14 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 15 | } 16 | e.Value += e2.Payload().(int64) 17 | return nil 18 | } 19 | 20 | // Payload returns the aggregated value for this event 21 | func (e Total) Payload() interface{} { 22 | return e.Value 23 | } 24 | 25 | // Stats returns an array of StatsD events as they travel over UDP 26 | func (e Total) Stats() []string { 27 | return []string{fmt.Sprintf("%s:%d|t", e.Name, e.Value)} 28 | } 29 | 30 | // Key returns the name of this metric 31 | func (e Total) Key() string { 32 | return e.Name 33 | } 34 | 35 | // SetKey sets the name of this metric 36 | func (e *Total) SetKey(key string) { 37 | e.Name = key 38 | } 39 | 40 | // Type returns an integer identifier for this type of metric 41 | func (e Total) Type() int { 42 | return EventTotal 43 | } 44 | 45 | // TypeString returns a name for this type of metric 46 | func (e Total) TypeString() string { 47 | return "Total" 48 | } 49 | 50 | // String returns a debug-friendly representation of this metric 51 | func (e Total) String() string { 52 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %d}", e.TypeString(), e.Name, e.Value) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 Google Inc. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/increment.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // Increment represents a metric whose value is averaged over a minute 6 | type Increment struct { 7 | Name string 8 | Value int64 9 | } 10 | 11 | // Update the event with metrics coming from a new one of the same type and with the same key 12 | func (e *Increment) Update(e2 Event) error { 13 | if e.Type() != e2.Type() { 14 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 15 | } 16 | e.Value += e2.Payload().(int64) 17 | return nil 18 | } 19 | 20 | // Payload returns the aggregated value for this event 21 | func (e Increment) Payload() interface{} { 22 | return e.Value 23 | } 24 | 25 | // Stats returns an array of StatsD events as they travel over UDP 26 | func (e Increment) Stats() []string { 27 | return []string{fmt.Sprintf("%s:%d|c", e.Name, e.Value)} 28 | } 29 | 30 | // Key returns the name of this metric 31 | func (e Increment) Key() string { 32 | return e.Name 33 | } 34 | 35 | // SetKey sets the name of this metric 36 | func (e *Increment) SetKey(key string) { 37 | e.Name = key 38 | } 39 | 40 | // Type returns an integer identifier for this type of metric 41 | func (e Increment) Type() int { 42 | return EventIncr 43 | } 44 | 45 | // TypeString returns a name for this type of metric 46 | func (e Increment) TypeString() string { 47 | return "Increment" 48 | } 49 | 50 | // String returns a debug-friendly representation of this metric 51 | func (e Increment) String() string { 52 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %d}", e.TypeString(), e.Name, e.Value) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/mb0/glob/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 The Go Authors for the original package path/filepath. 2 | Copyright 2012 Martin Schnabel for modifications. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/ioutils/writers_test.go: -------------------------------------------------------------------------------- 1 | package ioutils 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | "testing" 7 | ) 8 | 9 | func TestWriteCloserWrapperClose(t *testing.T) { 10 | called := false 11 | writer := bytes.NewBuffer([]byte{}) 12 | wrapper := NewWriteCloserWrapper(writer, func() error { 13 | called = true 14 | return nil 15 | }) 16 | if err := wrapper.Close(); err != nil { 17 | t.Fatal(err) 18 | } 19 | if !called { 20 | t.Fatalf("writeCloserWrapper should have call the anonymous function.") 21 | } 22 | } 23 | 24 | func TestNopWriteCloser(t *testing.T) { 25 | writer := bytes.NewBuffer([]byte{}) 26 | wrapper := NopWriteCloser(writer) 27 | if err := wrapper.Close(); err != nil { 28 | t.Fatal("NopWriteCloser always return nil on Close.") 29 | } 30 | 31 | } 32 | 33 | func TestNopWriter(t *testing.T) { 34 | nw := &NopWriter{} 35 | l, err := nw.Write([]byte{'c'}) 36 | if err != nil { 37 | t.Fatal(err) 38 | } 39 | if l != 1 { 40 | t.Fatalf("Expected 1 got %d", l) 41 | } 42 | } 43 | 44 | func TestWriteCounter(t *testing.T) { 45 | dummy1 := "This is a dummy string." 46 | dummy2 := "This is another dummy string." 47 | totalLength := int64(len(dummy1) + len(dummy2)) 48 | 49 | reader1 := strings.NewReader(dummy1) 50 | reader2 := strings.NewReader(dummy2) 51 | 52 | var buffer bytes.Buffer 53 | wc := NewWriteCounter(&buffer) 54 | 55 | reader1.WriteTo(wc) 56 | reader2.WriteTo(wc) 57 | 58 | if wc.Count != totalLength { 59 | t.Errorf("Wrong count: %d vs. %d", wc.Count, totalLength) 60 | } 61 | 62 | if buffer.String() != dummy1+dummy2 { 63 | t.Error("Wrong message written") 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/archive_unix_test.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package archive 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func TestCanonicalTarNameForPath(t *testing.T) { 11 | cases := []struct{ in, expected string }{ 12 | {"foo", "foo"}, 13 | {"foo/bar", "foo/bar"}, 14 | {"foo/dir/", "foo/dir/"}, 15 | } 16 | for _, v := range cases { 17 | if out, err := CanonicalTarNameForPath(v.in); err != nil { 18 | t.Fatalf("cannot get canonical name for path: %s: %v", v.in, err) 19 | } else if out != v.expected { 20 | t.Fatalf("wrong canonical tar name. expected:%s got:%s", v.expected, out) 21 | } 22 | } 23 | } 24 | 25 | func TestCanonicalTarName(t *testing.T) { 26 | cases := []struct { 27 | in string 28 | isDir bool 29 | expected string 30 | }{ 31 | {"foo", false, "foo"}, 32 | {"foo", true, "foo/"}, 33 | {"foo/bar", false, "foo/bar"}, 34 | {"foo/bar", true, "foo/bar/"}, 35 | } 36 | for _, v := range cases { 37 | if out, err := canonicalTarName(v.in, v.isDir); err != nil { 38 | t.Fatalf("cannot get canonical name for path: %s: %v", v.in, err) 39 | } else if out != v.expected { 40 | t.Fatalf("wrong canonical tar name. expected:%s got:%s", v.expected, out) 41 | } 42 | } 43 | } 44 | 45 | func TestChmodTarEntry(t *testing.T) { 46 | cases := []struct { 47 | in, expected os.FileMode 48 | }{ 49 | {0000, 0000}, 50 | {0777, 0777}, 51 | {0644, 0644}, 52 | {0755, 0755}, 53 | {0444, 0444}, 54 | } 55 | for _, v := range cases { 56 | if out := chmodTarEntry(v.in); out != v.expected { 57 | t.Fatalf("wrong chmod. expected:%v got:%v", v.expected, out) 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/filesys_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package system 4 | 5 | import ( 6 | "os" 7 | "regexp" 8 | "syscall" 9 | ) 10 | 11 | // MkdirAll implementation that is volume path aware for Windows. 12 | func MkdirAll(path string, perm os.FileMode) error { 13 | if re := regexp.MustCompile(`^\\\\\?\\Volume{[a-z0-9-]+}$`); re.MatchString(path) { 14 | return nil 15 | } 16 | 17 | // The rest of this method is copied from os.MkdirAll and should be kept 18 | // as-is to ensure compatibility. 19 | 20 | // Fast path: if we can tell whether path is a directory or file, stop with success or error. 21 | dir, err := os.Stat(path) 22 | if err == nil { 23 | if dir.IsDir() { 24 | return nil 25 | } 26 | return &os.PathError{ 27 | Op: "mkdir", 28 | Path: path, 29 | Err: syscall.ENOTDIR, 30 | } 31 | } 32 | 33 | // Slow path: make sure parent exists and then call Mkdir for path. 34 | i := len(path) 35 | for i > 0 && os.IsPathSeparator(path[i-1]) { // Skip trailing path separator. 36 | i-- 37 | } 38 | 39 | j := i 40 | for j > 0 && !os.IsPathSeparator(path[j-1]) { // Scan backward over element. 41 | j-- 42 | } 43 | 44 | if j > 1 { 45 | // Create parent 46 | err = MkdirAll(path[0:j-1], perm) 47 | if err != nil { 48 | return err 49 | } 50 | } 51 | 52 | // Parent now exists; invoke Mkdir and use its result. 53 | err = os.Mkdir(path, perm) 54 | if err != nil { 55 | // Handle arguments like "foo/." by 56 | // double-checking that directory doesn't exist. 57 | dir, err1 := os.Lstat(path) 58 | if err1 == nil && dir.IsDir() { 59 | return nil 60 | } 61 | return err 62 | } 63 | return nil 64 | } 65 | -------------------------------------------------------------------------------- /adapter_test.go: -------------------------------------------------------------------------------- 1 | package stats_test 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "testing" 7 | 8 | "github.com/fsouza/go-dockerclient" 9 | "github.com/remind101/dockerstats" 10 | ) 11 | 12 | func TestLogAdapter(t *testing.T) { 13 | b := new(bytes.Buffer) 14 | a, err := stats.NewLogAdapter(`{{.Type}}#{{.Name}}={{.Value}} source={{.Container.Name}}`, b) 15 | if err != nil { 16 | t.Fatal(err) 17 | } 18 | 19 | c := &docker.Container{ 20 | Name: "dummy", 21 | } 22 | 23 | a.Sample(c, "foo.bar", 1) 24 | if got, want := b.String(), "sample#foo.bar=1 source=dummy\n"; got != want { 25 | t.Errorf("Sample() => %q; want %q", got, want) 26 | } 27 | } 28 | 29 | type fakeStatsdClient struct { 30 | Stats []string 31 | } 32 | 33 | func (c *fakeStatsdClient) Incr(name string, value int64) error { 34 | return c.write(name, value, "c") 35 | } 36 | 37 | func (c *fakeStatsdClient) Gauge(name string, value int64) error { 38 | return c.write(name, value, "g") 39 | } 40 | 41 | func (c *fakeStatsdClient) write(name string, value int64, typ string) error { 42 | c.Stats = append(c.Stats, fmt.Sprintf("%s:%d|%s", name, value, typ)) 43 | return nil 44 | } 45 | 46 | func TestStatsdAdapter(t *testing.T) { 47 | client := &fakeStatsdClient{Stats: []string{}} 48 | a, err := stats.NewStatsdAdapter(client, `tests.source__{{.Env "SOURCE"}}__`) 49 | if err != nil { 50 | t.Fatal(err) 51 | } 52 | 53 | c := &docker.Container{ 54 | Name: "dummy", 55 | Config: &docker.Config{ 56 | Env: []string{"SOURCE=dockerstats.tests.statsd"}, 57 | }, 58 | } 59 | 60 | a.Incr(c, "foo.bar", 1) 61 | if got, want := client.Stats[0], "tests.source__dockerstats.tests.statsd__:1|c"; got != want { 62 | t.Errorf("Incr() => %q; want %q", got, want) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/wrap.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "archive/tar" 5 | "bytes" 6 | "io/ioutil" 7 | ) 8 | 9 | // Generate generates a new archive from the content provided 10 | // as input. 11 | // 12 | // `files` is a sequence of path/content pairs. A new file is 13 | // added to the archive for each pair. 14 | // If the last pair is incomplete, the file is created with an 15 | // empty content. For example: 16 | // 17 | // Generate("foo.txt", "hello world", "emptyfile") 18 | // 19 | // The above call will return an archive with 2 files: 20 | // * ./foo.txt with content "hello world" 21 | // * ./empty with empty content 22 | // 23 | // FIXME: stream content instead of buffering 24 | // FIXME: specify permissions and other archive metadata 25 | func Generate(input ...string) (Archive, error) { 26 | files := parseStringPairs(input...) 27 | buf := new(bytes.Buffer) 28 | tw := tar.NewWriter(buf) 29 | for _, file := range files { 30 | name, content := file[0], file[1] 31 | hdr := &tar.Header{ 32 | Name: name, 33 | Size: int64(len(content)), 34 | } 35 | if err := tw.WriteHeader(hdr); err != nil { 36 | return nil, err 37 | } 38 | if _, err := tw.Write([]byte(content)); err != nil { 39 | return nil, err 40 | } 41 | } 42 | if err := tw.Close(); err != nil { 43 | return nil, err 44 | } 45 | return ioutil.NopCloser(buf), nil 46 | } 47 | 48 | func parseStringPairs(input ...string) (output [][2]string) { 49 | output = make([][2]string, 0, len(input)/2+1) 50 | for i := 0; i < len(input); i += 2 { 51 | var pair [2]string 52 | pair[0] = input[i] 53 | if i+1 < len(input) { 54 | pair[1] = input[i+1] 55 | } 56 | output = append(output, pair) 57 | } 58 | return 59 | } 60 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/absolute.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // Absolute is a metric that is not averaged/aggregated. 6 | // We keep each value distinct and then we flush them all individually. 7 | type Absolute struct { 8 | Name string 9 | Values []int64 10 | } 11 | 12 | // Update the event with metrics coming from a new one of the same type and with the same key 13 | func (e *Absolute) Update(e2 Event) error { 14 | if e.Type() != e2.Type() { 15 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 16 | } 17 | e.Values = append(e.Values, e2.Payload().([]int64)...) 18 | return nil 19 | } 20 | 21 | // Payload returns the aggregated value for this event 22 | func (e Absolute) Payload() interface{} { 23 | return e.Values 24 | } 25 | 26 | // Stats returns an array of StatsD events as they travel over UDP 27 | func (e Absolute) Stats() []string { 28 | ret := make([]string, 0, len(e.Values)) 29 | for _, v := range e.Values { 30 | ret = append(ret, fmt.Sprintf("%s:%d|a", e.Name, v)) 31 | } 32 | return ret 33 | } 34 | 35 | // Key returns the name of this metric 36 | func (e Absolute) Key() string { 37 | return e.Name 38 | } 39 | 40 | // SetKey sets the name of this metric 41 | func (e *Absolute) SetKey(key string) { 42 | e.Name = key 43 | } 44 | 45 | // Type returns an integer identifier for this type of metric 46 | func (e Absolute) Type() int { 47 | return EventAbsolute 48 | } 49 | 50 | // TypeString returns a name for this type of metric 51 | func (e Absolute) TypeString() string { 52 | return "Absolute" 53 | } 54 | 55 | // String returns a debug-friendly representation of this metric 56 | func (e Absolute) String() string { 57 | return fmt.Sprintf("{Type: %s, Key: %s, Values: %v}", e.TypeString(), e.Name, e.Values) 58 | } 59 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/utimes_test.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "io/ioutil" 5 | "os" 6 | "path/filepath" 7 | "syscall" 8 | "testing" 9 | ) 10 | 11 | // prepareFiles creates files for testing in the temp directory 12 | func prepareFiles(t *testing.T) (string, string, string, string) { 13 | dir, err := ioutil.TempDir("", "docker-system-test") 14 | if err != nil { 15 | t.Fatal(err) 16 | } 17 | 18 | file := filepath.Join(dir, "exist") 19 | if err := ioutil.WriteFile(file, []byte("hello"), 0644); err != nil { 20 | t.Fatal(err) 21 | } 22 | 23 | invalid := filepath.Join(dir, "doesnt-exist") 24 | 25 | symlink := filepath.Join(dir, "symlink") 26 | if err := os.Symlink(file, symlink); err != nil { 27 | t.Fatal(err) 28 | } 29 | 30 | return file, invalid, symlink, dir 31 | } 32 | 33 | func TestLUtimesNano(t *testing.T) { 34 | file, invalid, symlink, dir := prepareFiles(t) 35 | defer os.RemoveAll(dir) 36 | 37 | before, err := os.Stat(file) 38 | if err != nil { 39 | t.Fatal(err) 40 | } 41 | 42 | ts := []syscall.Timespec{{0, 0}, {0, 0}} 43 | if err := LUtimesNano(symlink, ts); err != nil { 44 | t.Fatal(err) 45 | } 46 | 47 | symlinkInfo, err := os.Lstat(symlink) 48 | if err != nil { 49 | t.Fatal(err) 50 | } 51 | if before.ModTime().Unix() == symlinkInfo.ModTime().Unix() { 52 | t.Fatal("The modification time of the symlink should be different") 53 | } 54 | 55 | fileInfo, err := os.Stat(file) 56 | if err != nil { 57 | t.Fatal(err) 58 | } 59 | if before.ModTime().Unix() != fileInfo.ModTime().Unix() { 60 | t.Fatal("The modification time of the file should be same") 61 | } 62 | 63 | if err := LUtimesNano(invalid, ts); err == nil { 64 | t.Fatal("Doesn't return an error on a non-existing file") 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEowIBAAKCAQEAxgNZgIUjqWbKQ9XaWe6lREKyCcOF6PNudox2jkZxHQ4hZm+m 3 | 6xJq+o8PLeD9yBsW6gXP06kVfkkl8cGBFb36XkCh/kpqkraDDbQ91K2tetWs+FdA 4 | XMTLUpbFBqaM/v/0AgKvKomsTMIIsnOdud5pEJvPGp49nDbe8W3sIrvyhVrn+wVa 5 | TStfpbaSZpbpH3I/xviNW8O49SsQYw6xanuXMg7rmXAy9rZlFz/2Vg8l8Er/hwDn 6 | JKp+OM+ml5QZFbzlwwWSamO+nf71lQzQrmXl0Z6pYT97dZB+FdEUF6PiQ9rYLSYH 7 | VNLp88qBTkljVAT5u97apo1BhgJhhwZnnoCa/wIDAQABAoIBAQCaGy9EC9pmU95l 8 | DwGh7k5nIrUnTilg1FwLHWSDdCVCZKXv8ENrPelOWZqJrUo1u4eI2L8XTsewgkNq 9 | tJu/DRzWz9yDaO0qg6rZNobMh+K076lvmZA44twOydJLS8H+D7ua+PXU2FLlZjmY 10 | kMyXRJZmW6zCXZc7haTbJx6ZJccoquk/DkS4FcFurJP177u1YrWS9TTw9kensUtU 11 | jQ63uf56UTN1i+0+Rxl7OW1TZlqwlri5I4njg5249+FxwwHzIq8+l7zD7K9pl8c/ 12 | nG1HuulvU2bVlDlRdyslMPAH34vw9Sku1BD8furrJLr1na5lRSLKJODEaIPEsLwv 13 | CdEUwP9JAoGBAO76ZW80RyNB2fA+wbTq70Sr8CwrXxYemXrez5LKDC7SsohKFCPE 14 | IedpO/n+nmymiiJvMm874EExoG6BVrbkWkeb+2vinEfOQNlDMsDx7WLjPekP3t6i 15 | rXHO3CjFooVFq2z3mZa/Nc5NZqu8fNWNCKJxZDJphdoj6sORNJIUvZVjAoGBANQd 16 | ++J+ITcu3/+A6JrGcgLunBFQYPqkiItk0J4QKYKuX5ik9rWcQDN8TTtfW2mDuiQ4 17 | NrCwuVPq1V1kB16JzH017SsYLo9g8I20YjnBZge9pKTeUaLVTb3C50LW8FBylop0 18 | Bnm597dNbtSjphjoTMg0XyC19o3Esf2YeWG0QNS1AoGAWWDfFRNJU99qIldmXULM 19 | 0DM6NVrXSk+ReYnhunXEzrJQwXZrR+EwCPurydk36Uz0NuK9yypquhdUeF/5TZfk 20 | SAoHo5byekyipl9imRUigqyY2BTudvgCxKDoaHtaSFwBPFTyZZYICquaLbrmOXxw 21 | 8UhVgCFFRYvPXuts7QHC0h8CgYBWEvy9gfU0kV7wLX02IUTuj6jhFb7ktpN6DSTi 22 | nyhZES1VoctDEu6ydcRZTW6ouH12aSE4Pd5WgTqntQmQgVZrkNB25k8ue2Xh+srJ 23 | KQOgLIJ9LIHwE6KCWG7DnrjRzE3uTPq7to0g4tkQjH/AJ7PQof/gJDayfJjFkXPg 24 | A+cy6QKBgEPbKpiqscm03gT2QanBut5pg4dqPOxp0SlErA3kSFNTRK3oYBQPC+LH 25 | qA5nD5brdkeNBB58Rll8Zpzxiff50bcvLP/7/Sb3NjaXFTEY0gVbdRof3n6N0YP3 26 | Hu5XDNJ9RNkNzE5RIG1g86KE+aKlcrKMaigqAiuIy2PSnjkQeGk8 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/fabsolute.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // FAbsolute is a metric that is not averaged/aggregated. 6 | // We keep each value distinct and then we flush them all individually. 7 | type FAbsolute struct { 8 | Name string 9 | Values []float64 10 | } 11 | 12 | // Update the event with metrics coming from a new one of the same type and with the same key 13 | func (e *FAbsolute) Update(e2 Event) error { 14 | if e.Type() != e2.Type() { 15 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 16 | } 17 | e.Values = append(e.Values, e2.Payload().([]float64)...) 18 | return nil 19 | } 20 | 21 | // Payload returns the aggregated value for this event 22 | func (e FAbsolute) Payload() interface{} { 23 | return e.Values 24 | } 25 | 26 | // Stats returns an array of StatsD events as they travel over UDP 27 | func (e FAbsolute) Stats() []string { 28 | ret := make([]string, 0, len(e.Values)) 29 | for _, v := range e.Values { 30 | ret = append(ret, fmt.Sprintf("%s:%g|a", e.Name, v)) 31 | } 32 | return ret 33 | } 34 | 35 | // Key returns the name of this metric 36 | func (e FAbsolute) Key() string { 37 | return e.Name 38 | } 39 | 40 | // SetKey sets the name of this metric 41 | func (e *FAbsolute) SetKey(key string) { 42 | e.Name = key 43 | } 44 | 45 | // Type returns an integer identifier for this type of metric 46 | func (e FAbsolute) Type() int { 47 | return EventFAbsolute 48 | } 49 | 50 | // TypeString returns a name for this type of metric 51 | func (e FAbsolute) TypeString() string { 52 | return "FAbsolute" 53 | } 54 | 55 | // String returns a debug-friendly representation of this metric 56 | func (e FAbsolute) String() string { 57 | return fmt.Sprintf("{Type: %s, Key: %s, Values: %v}", e.TypeString(), e.Name, e.Values) 58 | } 59 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/serverkey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEoAIBAAKCAQEA3FQ5SE2eoWetOUuwFjN8VFlZCjbryX7griU4kJVt8Oic/eAz 3 | PS8aL19zIWoRZIDxj5KFedrrbkdOdF4LAV2y7TzrWoIiru/3mEUULI57SIjGl3QA 4 | oueX3R37W+icTtqd2AWCihttOIyXLhQrgfrPwPXjx8U0iKGi144bc8gXz1MXE/sI 5 | n/fBefH8gql2U7w8Ce5ve0E8ke8YOPso5EvLggHFFflUEB18Y3JsTrp9yt6ES9qs 6 | sDib2mCJpH82ev0V0qE/Kph2N+Us2/PJ3E28whXgzSEWWFeZi+kyMDn9exOezJW3 7 | 0kclrlSnCqxud7Ty3uuybuWJk3FmWSjzE85NBwIDAQABAoIBAG0ak+cW8LeShHf7 8 | 3+2Of0GxoOLrAWWdG5uAuPr31CJYve0FybnBimDtDjD8ujIfm/7xmoEWBEFutA3x 9 | x9dcU88gvJbsHEqub9gKVQwfXjMz78tt2SbSMiR/xUnk7QorPcCMMfE71aEMFYzu 10 | 1gCed6Rg3vO81t/V0rKVH0j9S7UQz5v/oX15eVDV5LOqyCHwAi6K0eXXbqnbI0TH 11 | SOQ/nexM2msVXWbO9t6ra6f5V7FXziDK5Xi+rPxRbX9mkrDzxDAevfuRqYBx5vtL 12 | W2Q2hKjUAHFgXFniNSZBS7dCdAtz0el/3ct+cNmpuTMhhs7M6wC1CuYiZ/DxLiFh 13 | Si73VckCgYEA+/ceh3+VjtQ0rgEw8sD9bqYEA8IaBiObjneIoFnKBYRG7yZd8JMm 14 | HD4M/aQ1qhcRLPN7GR03YQULgQJURbKSjJHnhfTXHyeHC3NN4gMVHQXewu2MHCh6 15 | 7FCQ9CfK0KcYLgegVVvL3PrF3hyWGnmTu+G0UkDQRYVnaNrB7snrW6UCgYEA39tq 16 | +MCQdu0moJ5szSZf02undg9EeW6isk9qzi7TId3/MLci2eH7PEnipipPUK3+DERq 17 | aba0y0TKgBR2EXvXLFJA/+kfdo2loIEHOfox85HVfxgUaFRti63ZI0uF8D0QT2Yy 18 | oJal+RFghVoSnv4LjhRKEPbIkScTXGjdK+7wFjsCfz79iKRXQQx0ALd/lL0bgkAn 19 | QNmvrNHcFQeI2p8700WNzC39aX67SsvEt3qxkrjzC1gxhpTAuReIK1gVPPwvqHN8 20 | BmV20FD5kMlMCix2mNCopwgUWvKvLAvoGFTxncKMA39+aJbuXAjiqJTekKgNvOE7 21 | i9kEWw0GTNPp3JHV6QECgYAPwb0M11kT1euDIMOdyRazpf86kyaJuZzgGjD1ZFxe 22 | JOcigbGFTp/FhZnbglzk2+pm6KXo3QBq0mPCki4hWusxZnTGzpz1VlETNCHTFeZQ 23 | M7KoaIR/N3oie9Et59H8r/+m5xWnMhNqratyl316DX24uXrhKM3DUdHODl+LCR2D 24 | IwKBgE1MbHuwolUPEw3HeO4R7NMFVTFei7E/fpUsimPfArGg8UydwvloNT1myJos 25 | N2JzfGGjN2KPVcBk9fOs71mJ6VcK3C3g5JIccplk6h9VNaw55+zdQvKPTzoBoTvy 26 | A+Fwx2AlF61KeRF87DL2YTRJ6B9MHmWgf7+GVZOxomLgEAcZ 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/misc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | import ( 8 | "bytes" 9 | "strings" 10 | ) 11 | 12 | // Version returns version information about the docker server. 13 | // 14 | // See http://goo.gl/BOZrF5 for more details. 15 | func (c *Client) Version() (*Env, error) { 16 | body, _, err := c.do("GET", "/version", doOptions{}) 17 | if err != nil { 18 | return nil, err 19 | } 20 | var env Env 21 | if err := env.Decode(bytes.NewReader(body)); err != nil { 22 | return nil, err 23 | } 24 | return &env, nil 25 | } 26 | 27 | // Info returns system-wide information about the Docker server. 28 | // 29 | // See http://goo.gl/wmqZsW for more details. 30 | func (c *Client) Info() (*Env, error) { 31 | body, _, err := c.do("GET", "/info", doOptions{}) 32 | if err != nil { 33 | return nil, err 34 | } 35 | var info Env 36 | err = info.Decode(bytes.NewReader(body)) 37 | if err != nil { 38 | return nil, err 39 | } 40 | return &info, nil 41 | } 42 | 43 | // ParseRepositoryTag gets the name of the repository and returns it splitted 44 | // in two parts: the repository and the tag. 45 | // 46 | // Some examples: 47 | // 48 | // localhost.localdomain:5000/samalba/hipache:latest -> localhost.localdomain:5000/samalba/hipache, latest 49 | // localhost.localdomain:5000/samalba/hipache -> localhost.localdomain:5000/samalba/hipache, "" 50 | func ParseRepositoryTag(repoTag string) (repository string, tag string) { 51 | n := strings.LastIndex(repoTag, ":") 52 | if n < 0 { 53 | return repoTag, "" 54 | } 55 | if tag := repoTag[n+1:]; !strings.Contains(tag, "/") { 56 | return repoTag[:n], tag 57 | } 58 | return repoTag, "" 59 | } 60 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/noopclient.go: -------------------------------------------------------------------------------- 1 | package statsd 2 | 3 | //@author https://github.com/wyndhblb/statsd 4 | 5 | import ( 6 | "time" 7 | ) 8 | 9 | // NoopClient implements a "no-op" statsd in case there is no statsd server 10 | type NoopClient struct{} 11 | 12 | // CreateSocket does nothing 13 | func (s NoopClient) CreateSocket() error { 14 | return nil 15 | } 16 | 17 | // Close does nothing 18 | func (s NoopClient) Close() error { 19 | return nil 20 | } 21 | 22 | // Incr does nothing 23 | func (s NoopClient) Incr(stat string, count int64) error { 24 | return nil 25 | } 26 | 27 | // Decr does nothing 28 | func (s NoopClient) Decr(stat string, count int64) error { 29 | return nil 30 | } 31 | 32 | // Timing does nothing 33 | func (s NoopClient) Timing(stat string, count int64) error { 34 | return nil 35 | } 36 | 37 | // PrecisionTiming does nothing 38 | func (s NoopClient) PrecisionTiming(stat string, delta time.Duration) error { 39 | return nil 40 | } 41 | 42 | // Gauge does nothing 43 | func (s NoopClient) Gauge(stat string, value int64) error { 44 | return nil 45 | } 46 | 47 | // GaugeDelta does nothing 48 | func (s NoopClient) GaugeDelta(stat string, value int64) error { 49 | return nil 50 | } 51 | 52 | // Absolute does nothing 53 | func (s NoopClient) Absolute(stat string, value int64) error { 54 | return nil 55 | } 56 | 57 | // Total does nothing 58 | func (s NoopClient) Total(stat string, value int64) error { 59 | return nil 60 | } 61 | 62 | // FGauge does nothing 63 | func (s NoopClient) FGauge(stat string, value float64) error { 64 | return nil 65 | } 66 | 67 | // FGaugeDelta does nothing 68 | func (s NoopClient) FGaugeDelta(stat string, value float64) error { 69 | return nil 70 | } 71 | 72 | // FAbsolute does nothing 73 | func (s NoopClient) FAbsolute(stat string, value float64) error { 74 | return nil 75 | } 76 | -------------------------------------------------------------------------------- /cmd/stats/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/url" 7 | "os" 8 | 9 | "github.com/codegangsta/cli" 10 | "github.com/quipo/statsd" 11 | "github.com/remind101/dockerstats" 12 | ) 13 | 14 | var flags = []cli.Flag{ 15 | cli.StringFlag{ 16 | Name: "url", 17 | Value: "log://", 18 | EnvVar: "STAT_URL", 19 | }, 20 | cli.StringFlag{ 21 | Name: "template", 22 | Value: stats.L2MetTemplate, 23 | EnvVar: "STAT_TEMPLATE", 24 | }, 25 | cli.StringSliceFlag{ 26 | Name: "whitelist", 27 | Value: &cli.StringSlice{}, 28 | EnvVar: "STAT_WHITELIST", 29 | }, 30 | cli.IntFlag{ 31 | Name: "resolution", 32 | Value: stats.DefaultResolution, 33 | EnvVar: "RESOLUTION", 34 | }, 35 | } 36 | 37 | func main() { 38 | app := cli.NewApp() 39 | app.Name = "dockerstats" 40 | app.Flags = flags 41 | app.Action = run 42 | 43 | app.Run(os.Args) 44 | } 45 | 46 | func run(c *cli.Context) { 47 | stat, err := stats.New() 48 | must(err) 49 | 50 | stat.Adapter = newAdapter(c) 51 | stat.Resolution = c.Int("resolution") 52 | stat.Whitelist = c.StringSlice("whitelist") 53 | 54 | err = stat.Run() 55 | must(err) 56 | } 57 | 58 | func newAdapter(c *cli.Context) stats.Adapter { 59 | var ( 60 | a stats.Adapter 61 | err error 62 | ) 63 | 64 | u, err := url.Parse(c.String("url")) 65 | must(err) 66 | 67 | switch u.Scheme { 68 | case "log": 69 | a, err = stats.NewLogAdapter(c.String("template"), nil) 70 | case "statsd": 71 | client := statsd.NewStatsdClient(u.Host, "") 72 | err = client.CreateSocket() 73 | must(err) 74 | a, err = stats.NewStatsdAdapter(client, c.String("template")) 75 | default: 76 | err = fmt.Errorf("unable to find an adapter to handle: %s", c.String("url")) 77 | } 78 | 79 | must(err) 80 | return a 81 | } 82 | 83 | func must(err error) { 84 | if err != nil { 85 | log.Fatal(err) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/meminfo_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "io" 7 | "os" 8 | "strconv" 9 | "strings" 10 | 11 | "github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/units" 12 | ) 13 | 14 | var ( 15 | ErrMalformed = errors.New("malformed file") 16 | ) 17 | 18 | // ReadMemInfo retrieves memory statistics of the host system and returns a 19 | // MemInfo type. 20 | func ReadMemInfo() (*MemInfo, error) { 21 | file, err := os.Open("/proc/meminfo") 22 | if err != nil { 23 | return nil, err 24 | } 25 | defer file.Close() 26 | return parseMemInfo(file) 27 | } 28 | 29 | // parseMemInfo parses the /proc/meminfo file into 30 | // a MemInfo object given a io.Reader to the file. 31 | // 32 | // Throws error if there are problems reading from the file 33 | func parseMemInfo(reader io.Reader) (*MemInfo, error) { 34 | meminfo := &MemInfo{} 35 | scanner := bufio.NewScanner(reader) 36 | for scanner.Scan() { 37 | // Expected format: ["MemTotal:", "1234", "kB"] 38 | parts := strings.Fields(scanner.Text()) 39 | 40 | // Sanity checks: Skip malformed entries. 41 | if len(parts) < 3 || parts[2] != "kB" { 42 | continue 43 | } 44 | 45 | // Convert to bytes. 46 | size, err := strconv.Atoi(parts[1]) 47 | if err != nil { 48 | continue 49 | } 50 | bytes := int64(size) * units.KiB 51 | 52 | switch parts[0] { 53 | case "MemTotal:": 54 | meminfo.MemTotal = bytes 55 | case "MemFree:": 56 | meminfo.MemFree = bytes 57 | case "SwapTotal:": 58 | meminfo.SwapTotal = bytes 59 | case "SwapFree:": 60 | meminfo.SwapFree = bytes 61 | } 62 | 63 | } 64 | 65 | // Handle errors that may have occurred during the reading of the file. 66 | if err := scanner.Err(); err != nil { 67 | return nil, err 68 | } 69 | 70 | return meminfo, nil 71 | } 72 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "crypto/md5" 9 | "crypto/sha1" 10 | "hash" 11 | ) 12 | 13 | // Well known Name Space IDs and UUIDs 14 | var ( 15 | NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8") 16 | NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8") 17 | NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8") 18 | NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8") 19 | NIL = Parse("00000000-0000-0000-0000-000000000000") 20 | ) 21 | 22 | // NewHash returns a new UUID dervied from the hash of space concatenated with 23 | // data generated by h. The hash should be at least 16 byte in length. The 24 | // first 16 bytes of the hash are used to form the UUID. The version of the 25 | // UUID will be the lower 4 bits of version. NewHash is used to implement 26 | // NewMD5 and NewSHA1. 27 | func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID { 28 | h.Reset() 29 | h.Write(space) 30 | h.Write([]byte(data)) 31 | s := h.Sum(nil) 32 | uuid := make([]byte, 16) 33 | copy(uuid, s) 34 | uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4) 35 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant 36 | return uuid 37 | } 38 | 39 | // NewMD5 returns a new MD5 (Version 3) UUID based on the 40 | // supplied name space and data. 41 | // 42 | // NewHash(md5.New(), space, data, 3) 43 | func NewMD5(space UUID, data []byte) UUID { 44 | return NewHash(md5.New(), space, data, 3) 45 | } 46 | 47 | // NewSHA1 returns a new SHA1 (Version 5) UUID based on the 48 | // supplied name space and data. 49 | // 50 | // NewHash(sha1.New(), space, data, 5) 51 | func NewSHA1(space UUID, data []byte) UUID { 52 | return NewHash(sha1.New(), space, data, 5) 53 | } 54 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/system/xattrs_linux.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | // Returns a nil slice and nil error if the xattr is not set 9 | func Lgetxattr(path string, attr string) ([]byte, error) { 10 | pathBytes, err := syscall.BytePtrFromString(path) 11 | if err != nil { 12 | return nil, err 13 | } 14 | attrBytes, err := syscall.BytePtrFromString(attr) 15 | if err != nil { 16 | return nil, err 17 | } 18 | 19 | dest := make([]byte, 128) 20 | destBytes := unsafe.Pointer(&dest[0]) 21 | sz, _, errno := syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 22 | if errno == syscall.ENODATA { 23 | return nil, nil 24 | } 25 | if errno == syscall.ERANGE { 26 | dest = make([]byte, sz) 27 | destBytes := unsafe.Pointer(&dest[0]) 28 | sz, _, errno = syscall.Syscall6(syscall.SYS_LGETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(destBytes), uintptr(len(dest)), 0, 0) 29 | } 30 | if errno != 0 { 31 | return nil, errno 32 | } 33 | 34 | return dest[:sz], nil 35 | } 36 | 37 | var _zero uintptr 38 | 39 | func Lsetxattr(path string, attr string, data []byte, flags int) error { 40 | pathBytes, err := syscall.BytePtrFromString(path) 41 | if err != nil { 42 | return err 43 | } 44 | attrBytes, err := syscall.BytePtrFromString(attr) 45 | if err != nil { 46 | return err 47 | } 48 | var dataBytes unsafe.Pointer 49 | if len(data) > 0 { 50 | dataBytes = unsafe.Pointer(&data[0]) 51 | } else { 52 | dataBytes = unsafe.Pointer(&_zero) 53 | } 54 | _, _, errno := syscall.Syscall6(syscall.SYS_LSETXATTR, uintptr(unsafe.Pointer(pathBytes)), uintptr(unsafe.Pointer(attrBytes)), uintptr(dataBytes), uintptr(len(data)), uintptr(flags), 0) 55 | if errno != 0 { 56 | return errno 57 | } 58 | return nil 59 | } 60 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/archive_windows_test.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package archive 4 | 5 | import ( 6 | "os" 7 | "testing" 8 | ) 9 | 10 | func TestCanonicalTarNameForPath(t *testing.T) { 11 | cases := []struct { 12 | in, expected string 13 | shouldFail bool 14 | }{ 15 | {"foo", "foo", false}, 16 | {"foo/bar", "___", true}, // unix-styled windows path must fail 17 | {`foo\bar`, "foo/bar", false}, 18 | } 19 | for _, v := range cases { 20 | if out, err := CanonicalTarNameForPath(v.in); err != nil && !v.shouldFail { 21 | t.Fatalf("cannot get canonical name for path: %s: %v", v.in, err) 22 | } else if v.shouldFail && err == nil { 23 | t.Fatalf("canonical path call should have failed with error. in=%s out=%s", v.in, out) 24 | } else if !v.shouldFail && out != v.expected { 25 | t.Fatalf("wrong canonical tar name. expected:%s got:%s", v.expected, out) 26 | } 27 | } 28 | } 29 | 30 | func TestCanonicalTarName(t *testing.T) { 31 | cases := []struct { 32 | in string 33 | isDir bool 34 | expected string 35 | }{ 36 | {"foo", false, "foo"}, 37 | {"foo", true, "foo/"}, 38 | {`foo\bar`, false, "foo/bar"}, 39 | {`foo\bar`, true, "foo/bar/"}, 40 | } 41 | for _, v := range cases { 42 | if out, err := canonicalTarName(v.in, v.isDir); err != nil { 43 | t.Fatalf("cannot get canonical name for path: %s: %v", v.in, err) 44 | } else if out != v.expected { 45 | t.Fatalf("wrong canonical tar name. expected:%s got:%s", v.expected, out) 46 | } 47 | } 48 | } 49 | 50 | func TestChmodTarEntry(t *testing.T) { 51 | cases := []struct { 52 | in, expected os.FileMode 53 | }{ 54 | {0000, 0111}, 55 | {0777, 0755}, 56 | {0644, 0755}, 57 | {0755, 0755}, 58 | {0444, 0555}, 59 | } 60 | for _, v := range cases { 61 | if out := chmodTarEntry(v.in); out != v.expected { 62 | t.Fatalf("wrong chmod. expected:%v got:%v", v.expected, out) 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/trace/trace.go: -------------------------------------------------------------------------------- 1 | package trace 2 | 3 | import ( 4 | "runtime" 5 | "time" 6 | 7 | "code.google.com/p/go-uuid/uuid" 8 | 9 | "github.com/remind101/pkg/logger" 10 | "github.com/remind101/pkg/reporter" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // newID is used internally to generate a trace id. 15 | var newID = uuid.New 16 | 17 | func Trace(ctx context.Context) (context.Context, func(error, string, ...interface{})) { 18 | pc, file, line, _ := runtime.Caller(1) 19 | f := runtime.FuncForPC(pc) 20 | ctx = &tracedContext{ 21 | Context: ctx, 22 | id: newID(), 23 | parent: traceID(ctx), 24 | start: time.Now(), 25 | fnname: f.Name(), 26 | file: file, 27 | line: line, 28 | } 29 | 30 | return ctx, func(err error, msg string, pairs ...interface{}) { 31 | l, ok := logger.WithValues(ctx, "trace.id", "trace.parent", "trace.func", "trace.file", "trace.line", "trace.duration") 32 | if ok { 33 | l.Info(msg, pairs...) 34 | } 35 | 36 | // Report the error to the reporter. 37 | reporter.ReportWithSkip(ctx, err, 1) 38 | } 39 | } 40 | 41 | // tracedContext is a context.Context implementation that provides information 42 | // about a trace. 43 | type tracedContext struct { 44 | context.Context 45 | start time.Time 46 | id string 47 | parent string 48 | fnname string 49 | file string 50 | line int 51 | } 52 | 53 | func (ctx *tracedContext) Value(v interface{}) interface{} { 54 | if key, ok := v.(string); ok { 55 | switch key { 56 | case "trace.id": 57 | return ctx.id 58 | case "trace.parent": 59 | return ctx.parent 60 | case "trace.func": 61 | return ctx.fnname 62 | case "trace.file": 63 | return ctx.file 64 | case "trace.line": 65 | return ctx.line 66 | case "trace.duration": 67 | return time.Since(ctx.start) 68 | } 69 | } 70 | 71 | return ctx.Context.Value(v) 72 | } 73 | 74 | func traceID(ctx context.Context) string { 75 | id, _ := ctx.Value("trace.id").(string) 76 | return id 77 | } 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/text_formatter_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "testing" 7 | "time" 8 | ) 9 | 10 | func TestQuoting(t *testing.T) { 11 | tf := &TextFormatter{DisableColors: true} 12 | 13 | checkQuoting := func(q bool, value interface{}) { 14 | b, _ := tf.Format(WithField("test", value)) 15 | idx := bytes.Index(b, ([]byte)("test=")) 16 | cont := bytes.Contains(b[idx+5:], []byte{'"'}) 17 | if cont != q { 18 | if q { 19 | t.Errorf("quoting expected for: %#v", value) 20 | } else { 21 | t.Errorf("quoting not expected for: %#v", value) 22 | } 23 | } 24 | } 25 | 26 | checkQuoting(false, "abcd") 27 | checkQuoting(false, "v1.0") 28 | checkQuoting(false, "1234567890") 29 | checkQuoting(true, "/foobar") 30 | checkQuoting(true, "x y") 31 | checkQuoting(true, "x,y") 32 | checkQuoting(false, errors.New("invalid")) 33 | checkQuoting(true, errors.New("invalid argument")) 34 | } 35 | 36 | func TestTimestampFormat(t *testing.T) { 37 | checkTimeStr := func(format string) { 38 | customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format} 39 | customStr, _ := customFormatter.Format(WithField("test", "test")) 40 | timeStart := bytes.Index(customStr, ([]byte)("time=")) 41 | timeEnd := bytes.Index(customStr, ([]byte)("level=")) 42 | timeStr := customStr[timeStart+5 : timeEnd-1] 43 | if timeStr[0] == '"' && timeStr[len(timeStr)-1] == '"' { 44 | timeStr = timeStr[1 : len(timeStr)-1] 45 | } 46 | if format == "" { 47 | format = time.RFC3339 48 | } 49 | _, e := time.Parse(format, (string)(timeStr)) 50 | if e != nil { 51 | t.Errorf("time string \"%s\" did not match provided time format \"%s\": %s", timeStr, format, e) 52 | } 53 | } 54 | 55 | checkTimeStr("2006-01-02T15:04:05.000000000Z07:00") 56 | checkTimeStr("Mon Jan _2 15:04:05 2006") 57 | checkTimeStr("") 58 | } 59 | 60 | // TODO add tests for sorting etc., this requires a parser for the text 61 | // formatter output. 62 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/container.tar: -------------------------------------------------------------------------------- 1 | fakecontainer000644 000766 000024 00000000065 12210121775 016021 0ustar00flavia.carlettestaff000000 000000 this is supposed to be a fake container in a tar. xD 2 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "io" 9 | ) 10 | 11 | // randomBits completely fills slice b with random data. 12 | func randomBits(b []byte) { 13 | if _, err := io.ReadFull(rander, b); err != nil { 14 | panic(err.Error()) // rand should never fail 15 | } 16 | } 17 | 18 | // xvalues returns the value of a byte as a hexadecimal digit or 255. 19 | var xvalues = []byte{ 20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255, 24 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 25 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 26 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 27 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 28 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 29 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 30 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 31 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 32 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 33 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 34 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 35 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 36 | } 37 | 38 | // xtob converts the the first two hex bytes of x into a byte. 39 | func xtob(x string) (byte, bool) { 40 | b1 := xvalues[x[0]] 41 | b2 := xvalues[x[1]] 42 | return (b1 << 4) | b2, b1 != 255 && b2 != 255 43 | } 44 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/gauge.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // Gauge - Gauges are a constant data type. They are not subject to averaging, 6 | // and they don’t change unless you change them. That is, once you set a gauge value, 7 | // it will be a flat line on the graph until you change it again 8 | type Gauge struct { 9 | Name string 10 | Value int64 11 | } 12 | 13 | // Update the event with metrics coming from a new one of the same type and with the same key 14 | func (e *Gauge) Update(e2 Event) error { 15 | if e.Type() != e2.Type() { 16 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 17 | } 18 | e.Value = e2.Payload().(int64) 19 | return nil 20 | } 21 | 22 | // Payload returns the aggregated value for this event 23 | func (e Gauge) Payload() interface{} { 24 | return e.Value 25 | } 26 | 27 | // Stats returns an array of StatsD events as they travel over UDP 28 | func (e Gauge) Stats() []string { 29 | if e.Value < 0 { 30 | // because a leading '+' or '-' in the value of a gauge denotes a delta, to send 31 | // a negative gauge value we first set the gauge absolutely to 0, then send the 32 | // negative value as a delta from 0 (that's just how the spec works :-) 33 | return []string{ 34 | fmt.Sprintf("%s:%d|g", e.Name, 0), 35 | fmt.Sprintf("%s:%d|g", e.Name, e.Value), 36 | } 37 | } 38 | return []string{fmt.Sprintf("%s:%d|g", e.Name, e.Value)} 39 | } 40 | 41 | // Key returns the name of this metric 42 | func (e Gauge) Key() string { 43 | return e.Name 44 | } 45 | 46 | // SetKey sets the name of this metric 47 | func (e *Gauge) SetKey(key string) { 48 | e.Name = key 49 | } 50 | 51 | // Type returns an integer identifier for this type of metric 52 | func (e Gauge) Type() int { 53 | return EventGauge 54 | } 55 | 56 | // TypeString returns a name for this type of metric 57 | func (e Gauge) TypeString() string { 58 | return "Gauge" 59 | } 60 | 61 | // String returns a debug-friendly representation of this metric 62 | func (e Gauge) String() string { 63 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %d}", e.TypeString(), e.Name, e.Value) 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/fgauge.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // FGauge - Gauges are a constant data type. They are not subject to averaging, 6 | // and they don’t change unless you change them. That is, once you set a gauge value, 7 | // it will be a flat line on the graph until you change it again 8 | type FGauge struct { 9 | Name string 10 | Value float64 11 | } 12 | 13 | // Update the event with metrics coming from a new one of the same type and with the same key 14 | func (e *FGauge) Update(e2 Event) error { 15 | if e.Type() != e2.Type() { 16 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 17 | } 18 | e.Value += e2.Payload().(float64) 19 | return nil 20 | } 21 | 22 | // Payload returns the aggregated value for this event 23 | func (e FGauge) Payload() interface{} { 24 | return e.Value 25 | } 26 | 27 | // Stats returns an array of StatsD events as they travel over UDP 28 | func (e FGauge) Stats() []string { 29 | if e.Value < 0 { 30 | // because a leading '+' or '-' in the value of a gauge denotes a delta, to send 31 | // a negative gauge value we first set the gauge absolutely to 0, then send the 32 | // negative value as a delta from 0 (that's just how the spec works :-) 33 | return []string{ 34 | fmt.Sprintf("%s:%d|g", e.Name, 0), 35 | fmt.Sprintf("%s:%g|g", e.Name, e.Value), 36 | } 37 | } 38 | return []string{fmt.Sprintf("%s:%g|g", e.Name, e.Value)} 39 | } 40 | 41 | // Key returns the name of this metric 42 | func (e FGauge) Key() string { 43 | return e.Name 44 | } 45 | 46 | // SetKey sets the name of this metric 47 | func (e *FGauge) SetKey(key string) { 48 | e.Name = key 49 | } 50 | 51 | // Type returns an integer identifier for this type of metric 52 | func (e FGauge) Type() int { 53 | return EventFGauge 54 | } 55 | 56 | // TypeString returns a name for this type of metric 57 | func (e FGauge) TypeString() string { 58 | return "FGauge" 59 | } 60 | 61 | // String returns a debug-friendly representation of this metric 62 | func (e FGauge) String() string { 63 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %g}", e.TypeString(), e.Name, e.Value) 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/gaugedelta.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // GaugeDelta - Gauges are a constant data type. They are not subject to averaging, 6 | // and they don’t change unless you change them. That is, once you set a gauge value, 7 | // it will be a flat line on the graph until you change it again 8 | type GaugeDelta struct { 9 | Name string 10 | Value int64 11 | } 12 | 13 | // Update the event with metrics coming from a new one of the same type and with the same key 14 | func (e *GaugeDelta) Update(e2 Event) error { 15 | if e.Type() != e2.Type() { 16 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 17 | } 18 | e.Value += e2.Payload().(int64) 19 | return nil 20 | } 21 | 22 | // Payload returns the aggregated value for this event 23 | func (e GaugeDelta) Payload() interface{} { 24 | return e.Value 25 | } 26 | 27 | // Stats returns an array of StatsD events as they travel over UDP 28 | func (e GaugeDelta) Stats() []string { 29 | if e.Value < 0 { 30 | // because a leading '+' or '-' in the value of a gauge denotes a delta, to send 31 | // a negative gauge value we first set the gauge absolutely to 0, then send the 32 | // negative value as a delta from 0 (that's just how the spec works :-) 33 | return []string{ 34 | fmt.Sprintf("%s:%d|g", e.Name, 0), 35 | fmt.Sprintf("%s:%d|g", e.Name, e.Value), 36 | } 37 | } 38 | return []string{fmt.Sprintf("%s:%d|g", e.Name, e.Value)} 39 | } 40 | 41 | // Key returns the name of this metric 42 | func (e GaugeDelta) Key() string { 43 | return e.Name 44 | } 45 | 46 | // SetKey sets the name of this metric 47 | func (e *GaugeDelta) SetKey(key string) { 48 | e.Name = key 49 | } 50 | 51 | // Type returns an integer identifier for this type of metric 52 | func (e GaugeDelta) Type() int { 53 | return EventGaugeDelta 54 | } 55 | 56 | // TypeString returns a name for this type of metric 57 | func (e GaugeDelta) TypeString() string { 58 | return "GaugeDelta" 59 | } 60 | 61 | // String returns a debug-friendly representation of this metric 62 | func (e GaugeDelta) String() string { 63 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %d}", e.TypeString(), e.Name, e.Value) 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/fgaugedelta.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // FGaugeDelta - Gauges are a constant data type. They are not subject to averaging, 6 | // and they don’t change unless you change them. That is, once you set a gauge value, 7 | // it will be a flat line on the graph until you change it again 8 | type FGaugeDelta struct { 9 | Name string 10 | Value float64 11 | } 12 | 13 | // Update the event with metrics coming from a new one of the same type and with the same key 14 | func (e *FGaugeDelta) Update(e2 Event) error { 15 | if e.Type() != e2.Type() { 16 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 17 | } 18 | e.Value += e2.Payload().(float64) 19 | return nil 20 | } 21 | 22 | // Payload returns the aggregated value for this event 23 | func (e FGaugeDelta) Payload() interface{} { 24 | return e.Value 25 | } 26 | 27 | // Stats returns an array of StatsD events as they travel over UDP 28 | func (e FGaugeDelta) Stats() []string { 29 | if e.Value < 0 { 30 | // because a leading '+' or '-' in the value of a gauge denotes a delta, to send 31 | // a negative gauge value we first set the gauge absolutely to 0, then send the 32 | // negative value as a delta from 0 (that's just how the spec works :-) 33 | return []string{ 34 | fmt.Sprintf("%s:%d|g", e.Name, 0), 35 | fmt.Sprintf("%s:%g|g", e.Name, e.Value), 36 | } 37 | } 38 | return []string{fmt.Sprintf("%s:%g|g", e.Name, e.Value)} 39 | } 40 | 41 | // Key returns the name of this metric 42 | func (e FGaugeDelta) Key() string { 43 | return e.Name 44 | } 45 | 46 | // SetKey sets the name of this metric 47 | func (e *FGaugeDelta) SetKey(key string) { 48 | e.Name = key 49 | } 50 | 51 | // Type returns an integer identifier for this type of metric 52 | func (e FGaugeDelta) Type() int { 53 | return EventFGaugeDelta 54 | } 55 | 56 | // TypeString returns a name for this type of metric 57 | func (e FGaugeDelta) TypeString() string { 58 | return "FGaugeDelta" 59 | } 60 | 61 | // String returns a debug-friendly representation of this metric 62 | func (e FGaugeDelta) String() string { 63 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %g}", e.TypeString(), e.Name, e.Value) 64 | } 65 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/units/duration_test.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func TestHumanDuration(t *testing.T) { 9 | // Useful duration abstractions 10 | day := 24 * time.Hour 11 | week := 7 * day 12 | month := 30 * day 13 | year := 365 * day 14 | 15 | assertEquals(t, "Less than a second", HumanDuration(450*time.Millisecond)) 16 | assertEquals(t, "47 seconds", HumanDuration(47*time.Second)) 17 | assertEquals(t, "About a minute", HumanDuration(1*time.Minute)) 18 | assertEquals(t, "3 minutes", HumanDuration(3*time.Minute)) 19 | assertEquals(t, "35 minutes", HumanDuration(35*time.Minute)) 20 | assertEquals(t, "35 minutes", HumanDuration(35*time.Minute+40*time.Second)) 21 | assertEquals(t, "About an hour", HumanDuration(1*time.Hour)) 22 | assertEquals(t, "About an hour", HumanDuration(1*time.Hour+45*time.Minute)) 23 | assertEquals(t, "3 hours", HumanDuration(3*time.Hour)) 24 | assertEquals(t, "3 hours", HumanDuration(3*time.Hour+59*time.Minute)) 25 | assertEquals(t, "4 hours", HumanDuration(3*time.Hour+60*time.Minute)) 26 | assertEquals(t, "24 hours", HumanDuration(24*time.Hour)) 27 | assertEquals(t, "36 hours", HumanDuration(1*day+12*time.Hour)) 28 | assertEquals(t, "2 days", HumanDuration(2*day)) 29 | assertEquals(t, "7 days", HumanDuration(7*day)) 30 | assertEquals(t, "13 days", HumanDuration(13*day+5*time.Hour)) 31 | assertEquals(t, "2 weeks", HumanDuration(2*week)) 32 | assertEquals(t, "2 weeks", HumanDuration(2*week+4*day)) 33 | assertEquals(t, "3 weeks", HumanDuration(3*week)) 34 | assertEquals(t, "4 weeks", HumanDuration(4*week)) 35 | assertEquals(t, "4 weeks", HumanDuration(4*week+3*day)) 36 | assertEquals(t, "4 weeks", HumanDuration(1*month)) 37 | assertEquals(t, "6 weeks", HumanDuration(1*month+2*week)) 38 | assertEquals(t, "8 weeks", HumanDuration(2*month)) 39 | assertEquals(t, "3 months", HumanDuration(3*month+1*week)) 40 | assertEquals(t, "5 months", HumanDuration(5*month+2*week)) 41 | assertEquals(t, "13 months", HumanDuration(13*month)) 42 | assertEquals(t, "23 months", HumanDuration(23*month)) 43 | assertEquals(t, "24 months", HumanDuration(24*month)) 44 | assertEquals(t, "2 years", HumanDuration(24*month+2*week)) 45 | assertEquals(t, "3 years", HumanDuration(3*year+2*month)) 46 | } 47 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/formatter_bench_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | // smallFields is a small size data set for benchmarking 9 | var smallFields = Fields{ 10 | "foo": "bar", 11 | "baz": "qux", 12 | "one": "two", 13 | "three": "four", 14 | } 15 | 16 | // largeFields is a large size data set for benchmarking 17 | var largeFields = Fields{ 18 | "foo": "bar", 19 | "baz": "qux", 20 | "one": "two", 21 | "three": "four", 22 | "five": "six", 23 | "seven": "eight", 24 | "nine": "ten", 25 | "eleven": "twelve", 26 | "thirteen": "fourteen", 27 | "fifteen": "sixteen", 28 | "seventeen": "eighteen", 29 | "nineteen": "twenty", 30 | "a": "b", 31 | "c": "d", 32 | "e": "f", 33 | "g": "h", 34 | "i": "j", 35 | "k": "l", 36 | "m": "n", 37 | "o": "p", 38 | "q": "r", 39 | "s": "t", 40 | "u": "v", 41 | "w": "x", 42 | "y": "z", 43 | "this": "will", 44 | "make": "thirty", 45 | "entries": "yeah", 46 | } 47 | 48 | func BenchmarkSmallTextFormatter(b *testing.B) { 49 | doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields) 50 | } 51 | 52 | func BenchmarkLargeTextFormatter(b *testing.B) { 53 | doBenchmark(b, &TextFormatter{DisableColors: true}, largeFields) 54 | } 55 | 56 | func BenchmarkSmallColoredTextFormatter(b *testing.B) { 57 | doBenchmark(b, &TextFormatter{ForceColors: true}, smallFields) 58 | } 59 | 60 | func BenchmarkLargeColoredTextFormatter(b *testing.B) { 61 | doBenchmark(b, &TextFormatter{ForceColors: true}, largeFields) 62 | } 63 | 64 | func BenchmarkSmallJSONFormatter(b *testing.B) { 65 | doBenchmark(b, &JSONFormatter{}, smallFields) 66 | } 67 | 68 | func BenchmarkLargeJSONFormatter(b *testing.B) { 69 | doBenchmark(b, &JSONFormatter{}, largeFields) 70 | } 71 | 72 | func doBenchmark(b *testing.B, formatter Formatter, fields Fields) { 73 | entry := &Entry{ 74 | Time: time.Time{}, 75 | Level: InfoLevel, 76 | Message: "message", 77 | Data: fields, 78 | } 79 | var d []byte 80 | var err error 81 | for i := 0; i < b.N; i++ { 82 | d, err = formatter.Format(entry) 83 | if err != nil { 84 | b.Fatal(err) 85 | } 86 | b.SetBytes(int64(len(d))) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/context_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "flag" 5 | "testing" 6 | "time" 7 | 8 | "github.com/codegangsta/cli" 9 | ) 10 | 11 | func TestNewContext(t *testing.T) { 12 | set := flag.NewFlagSet("test", 0) 13 | set.Int("myflag", 12, "doc") 14 | globalSet := flag.NewFlagSet("test", 0) 15 | globalSet.Int("myflag", 42, "doc") 16 | command := cli.Command{Name: "mycommand"} 17 | c := cli.NewContext(nil, set, globalSet) 18 | c.Command = command 19 | expect(t, c.Int("myflag"), 12) 20 | expect(t, c.GlobalInt("myflag"), 42) 21 | expect(t, c.Command.Name, "mycommand") 22 | } 23 | 24 | func TestContext_Int(t *testing.T) { 25 | set := flag.NewFlagSet("test", 0) 26 | set.Int("myflag", 12, "doc") 27 | c := cli.NewContext(nil, set, set) 28 | expect(t, c.Int("myflag"), 12) 29 | } 30 | 31 | func TestContext_Duration(t *testing.T) { 32 | set := flag.NewFlagSet("test", 0) 33 | set.Duration("myflag", time.Duration(12*time.Second), "doc") 34 | c := cli.NewContext(nil, set, set) 35 | expect(t, c.Duration("myflag"), time.Duration(12*time.Second)) 36 | } 37 | 38 | func TestContext_String(t *testing.T) { 39 | set := flag.NewFlagSet("test", 0) 40 | set.String("myflag", "hello world", "doc") 41 | c := cli.NewContext(nil, set, set) 42 | expect(t, c.String("myflag"), "hello world") 43 | } 44 | 45 | func TestContext_Bool(t *testing.T) { 46 | set := flag.NewFlagSet("test", 0) 47 | set.Bool("myflag", false, "doc") 48 | c := cli.NewContext(nil, set, set) 49 | expect(t, c.Bool("myflag"), false) 50 | } 51 | 52 | func TestContext_BoolT(t *testing.T) { 53 | set := flag.NewFlagSet("test", 0) 54 | set.Bool("myflag", true, "doc") 55 | c := cli.NewContext(nil, set, set) 56 | expect(t, c.BoolT("myflag"), true) 57 | } 58 | 59 | func TestContext_Args(t *testing.T) { 60 | set := flag.NewFlagSet("test", 0) 61 | set.Bool("myflag", false, "doc") 62 | c := cli.NewContext(nil, set, set) 63 | set.Parse([]string{"--myflag", "bat", "baz"}) 64 | expect(t, len(c.Args()), 2) 65 | expect(t, c.Bool("myflag"), true) 66 | } 67 | 68 | func TestContext_IsSet(t *testing.T) { 69 | set := flag.NewFlagSet("test", 0) 70 | set.Bool("myflag", false, "doc") 71 | set.String("otherflag", "hello world", "doc") 72 | c := cli.NewContext(nil, set, set) 73 | set.Parse([]string{"--myflag", "bat", "baz"}) 74 | expect(t, c.IsSet("myflag"), true) 75 | expect(t, c.IsSet("otherflag"), false) 76 | expect(t, c.IsSet("bogusflag"), false) 77 | } 78 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/dce.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import ( 8 | "encoding/binary" 9 | "fmt" 10 | "os" 11 | ) 12 | 13 | // A Domain represents a Version 2 domain 14 | type Domain byte 15 | 16 | // Domain constants for DCE Security (Version 2) UUIDs. 17 | const ( 18 | Person = Domain(0) 19 | Group = Domain(1) 20 | Org = Domain(2) 21 | ) 22 | 23 | // NewDCESecurity returns a DCE Security (Version 2) UUID. 24 | // 25 | // The domain should be one of Person, Group or Org. 26 | // On a POSIX system the id should be the users UID for the Person 27 | // domain and the users GID for the Group. The meaning of id for 28 | // the domain Org or on non-POSIX systems is site defined. 29 | // 30 | // For a given domain/id pair the same token may be returned for up to 31 | // 7 minutes and 10 seconds. 32 | func NewDCESecurity(domain Domain, id uint32) UUID { 33 | uuid := NewUUID() 34 | if uuid != nil { 35 | uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2 36 | uuid[9] = byte(domain) 37 | binary.BigEndian.PutUint32(uuid[0:], id) 38 | } 39 | return uuid 40 | } 41 | 42 | // NewDCEPerson returns a DCE Security (Version 2) UUID in the person 43 | // domain with the id returned by os.Getuid. 44 | // 45 | // NewDCEPerson(Person, uint32(os.Getuid())) 46 | func NewDCEPerson() UUID { 47 | return NewDCESecurity(Person, uint32(os.Getuid())) 48 | } 49 | 50 | // NewDCEGroup returns a DCE Security (Version 2) UUID in the group 51 | // domain with the id returned by os.Getgid. 52 | // 53 | // NewDCEGroup(Group, uint32(os.Getgid())) 54 | func NewDCEGroup() UUID { 55 | return NewDCESecurity(Group, uint32(os.Getgid())) 56 | } 57 | 58 | // Domain returns the domain for a Version 2 UUID or false. 59 | func (uuid UUID) Domain() (Domain, bool) { 60 | if v, _ := uuid.Version(); v != 2 { 61 | return 0, false 62 | } 63 | return Domain(uuid[9]), true 64 | } 65 | 66 | // Id returns the id for a Version 2 UUID or false. 67 | func (uuid UUID) Id() (uint32, bool) { 68 | if v, _ := uuid.Version(); v != 2 { 69 | return 0, false 70 | } 71 | return binary.BigEndian.Uint32(uuid[0:4]), true 72 | } 73 | 74 | func (d Domain) String() string { 75 | switch d { 76 | case Person: 77 | return "Person" 78 | case Group: 79 | return "Group" 80 | case Org: 81 | return "Org" 82 | } 83 | return fmt.Sprintf("Domain%d", int(d)) 84 | } 85 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/README.md: -------------------------------------------------------------------------------- 1 | # StatsD client (Golang) 2 | 3 | [![GoDoc](https://godoc.org/github.com/quipo/statsd?status.png)](http://godoc.org/github.com/quipo/statsd) 4 | 5 | ## Introduction 6 | 7 | Go Client library for [StatsD](https://github.com/etsy/statsd/). Contains a direct and a buffered client. 8 | The buffered version will hold and aggregate values for the same key in memory before flushing them at the defined frequency. 9 | 10 | This client library was inspired by the one embedded in the [Bit.ly NSQ](https://github.com/bitly/nsq/blob/master/util/statsd_client.go) project, and extended to support some extra custom events used at DataSift. 11 | 12 | ## Installation 13 | 14 | go get github.com/quipo/statsd 15 | 16 | ## Supported event types 17 | 18 | * Increment - Count occurrences per second/minute of a specific event 19 | * Decrement - Count occurrences per second/minute of a specific event 20 | * Timing - To track a duration event 21 | * Gauge - Gauges are a constant data type. They are not subject to averaging, and they don’t change unless you change them. That is, once you set a gauge value, it will be a flat line on the graph until you change it again 22 | * Absolute - Absolute-valued metric (not averaged/aggregated) 23 | * Total - Continously increasing value, e.g. read operations since boot 24 | 25 | 26 | ## Sample usage 27 | 28 | ```go 29 | package main 30 | 31 | import ( 32 | "time" 33 | 34 | "github.com/quipo/statsd" 35 | ) 36 | 37 | func main() { 38 | // init 39 | prefix := "myproject." 40 | statsdclient := statsd.NewStatsdClient("localhost:8125", prefix) 41 | statsdclient.CreateSocket() 42 | interval := time.Second * 2 // aggregate stats and flush every 2 seconds 43 | stats := statsd.NewStatsdBuffer(interval, statsdclient) 44 | defer stats.Close() 45 | 46 | // not buffered: send immediately 47 | statsdclient.Incr("mymetric", 4) 48 | 49 | // buffered: aggregate in memory before flushing 50 | stats.Incr("mymetric", 1) 51 | stats.Incr("mymetric", 3) 52 | stats.Incr("mymetric", 1) 53 | stats.Incr("mymetric", 1) 54 | } 55 | ``` 56 | 57 | The string "%HOST%" in the metric name will automatically be replaced with the hostname of the server the event is sent from. 58 | 59 | 60 | ## Author 61 | 62 | Lorenzo Alberton 63 | 64 | * Web: [http://alberton.info](http://alberton.info) 65 | * Twitter: [@lorenzoalberton](https://twitter.com/lorenzoalberton) 66 | * Linkedin: [/in/lorenzoalberton](https://www.linkedin.com/in/lorenzoalberton) 67 | 68 | 69 | ## Copyright 70 | 71 | See [LICENSE](LICENSE) document 72 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/timing.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import "fmt" 4 | 5 | // Timing keeps min/max/avg information about a timer over a certain interval 6 | type Timing struct { 7 | Name string 8 | Min int64 9 | Max int64 10 | Value int64 11 | Count int64 12 | } 13 | 14 | // NewTiming is a factory for a Timing event, setting the Count to 1 to prevent div_by_0 errors 15 | func NewTiming(k string, delta int64) *Timing { 16 | return &Timing{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} 17 | } 18 | 19 | // Update the event with metrics coming from a new one of the same type and with the same key 20 | func (e *Timing) Update(e2 Event) error { 21 | if e.Type() != e2.Type() { 22 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 23 | } 24 | p := e2.Payload().(map[string]int64) 25 | e.Count += p["cnt"] 26 | e.Value += p["val"] 27 | e.Min = minInt64(e.Min, p["min"]) 28 | e.Max = maxInt64(e.Max, p["max"]) 29 | return nil 30 | } 31 | 32 | // Payload returns the aggregated value for this event 33 | func (e Timing) Payload() interface{} { 34 | return map[string]int64{ 35 | "min": e.Min, 36 | "max": e.Max, 37 | "val": e.Value, 38 | "cnt": e.Count, 39 | } 40 | } 41 | 42 | // Stats returns an array of StatsD events as they travel over UDP 43 | func (e Timing) Stats() []string { 44 | return []string{ 45 | fmt.Sprintf("%s.count:%d|a", e.Name, e.Count), 46 | fmt.Sprintf("%s.avg:%d|ms", e.Name, int64(e.Value/e.Count)), // make sure e.Count != 0 47 | fmt.Sprintf("%s.min:%d|ms", e.Name, e.Min), 48 | fmt.Sprintf("%s.max:%d|ms", e.Name, e.Max), 49 | } 50 | } 51 | 52 | // Key returns the name of this metric 53 | func (e Timing) Key() string { 54 | return e.Name 55 | } 56 | 57 | // SetKey sets the name of this metric 58 | func (e *Timing) SetKey(key string) { 59 | e.Name = key 60 | } 61 | 62 | // Type returns an integer identifier for this type of metric 63 | func (e Timing) Type() int { 64 | return EventTiming 65 | } 66 | 67 | // TypeString returns a name for this type of metric 68 | func (e Timing) TypeString() string { 69 | return "Timing" 70 | } 71 | 72 | // String returns a debug-friendly representation of this metric 73 | func (e Timing) String() string { 74 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %+v}", e.TypeString(), e.Name, e.Payload()) 75 | } 76 | 77 | func minInt64(v1, v2 int64) int64 { 78 | if v1 <= v2 { 79 | return v1 80 | } 81 | return v2 82 | } 83 | func maxInt64(v1, v2 int64) int64 { 84 | if v1 >= v2 { 85 | return v1 86 | } 87 | return v2 88 | } 89 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/stdcopy/stdcopy_test.go: -------------------------------------------------------------------------------- 1 | package stdcopy 2 | 3 | import ( 4 | "bytes" 5 | "io/ioutil" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | func TestNewStdWriter(t *testing.T) { 11 | writer := NewStdWriter(ioutil.Discard, Stdout) 12 | if writer == nil { 13 | t.Fatalf("NewStdWriter with an invalid StdType should not return nil.") 14 | } 15 | } 16 | 17 | func TestWriteWithUnitializedStdWriter(t *testing.T) { 18 | writer := StdWriter{ 19 | Writer: nil, 20 | prefix: Stdout, 21 | sizeBuf: make([]byte, 4), 22 | } 23 | n, err := writer.Write([]byte("Something here")) 24 | if n != 0 || err == nil { 25 | t.Fatalf("Should fail when given an uncomplete or uninitialized StdWriter") 26 | } 27 | } 28 | 29 | func TestWriteWithNilBytes(t *testing.T) { 30 | writer := NewStdWriter(ioutil.Discard, Stdout) 31 | n, err := writer.Write(nil) 32 | if err != nil { 33 | t.Fatalf("Shouldn't have fail when given no data") 34 | } 35 | if n > 0 { 36 | t.Fatalf("Write should have written 0 byte, but has written %d", n) 37 | } 38 | } 39 | 40 | func TestWrite(t *testing.T) { 41 | writer := NewStdWriter(ioutil.Discard, Stdout) 42 | data := []byte("Test StdWrite.Write") 43 | n, err := writer.Write(data) 44 | if err != nil { 45 | t.Fatalf("Error while writing with StdWrite") 46 | } 47 | if n != len(data) { 48 | t.Fatalf("Write should have writen %d byte but wrote %d.", len(data), n) 49 | } 50 | } 51 | 52 | func TestStdCopyWithInvalidInputHeader(t *testing.T) { 53 | dstOut := NewStdWriter(ioutil.Discard, Stdout) 54 | dstErr := NewStdWriter(ioutil.Discard, Stderr) 55 | src := strings.NewReader("Invalid input") 56 | _, err := StdCopy(dstOut, dstErr, src) 57 | if err == nil { 58 | t.Fatal("StdCopy with invalid input header should fail.") 59 | } 60 | } 61 | 62 | func TestStdCopyWithCorruptedPrefix(t *testing.T) { 63 | data := []byte{0x01, 0x02, 0x03} 64 | src := bytes.NewReader(data) 65 | written, err := StdCopy(nil, nil, src) 66 | if err != nil { 67 | t.Fatalf("StdCopy should not return an error with corrupted prefix.") 68 | } 69 | if written != 0 { 70 | t.Fatalf("StdCopy should have written 0, but has written %d", written) 71 | } 72 | } 73 | 74 | func BenchmarkWrite(b *testing.B) { 75 | w := NewStdWriter(ioutil.Discard, Stdout) 76 | data := []byte("Test line for testing stdwriter performance\n") 77 | data = bytes.Repeat(data, 100) 78 | b.SetBytes(int64(len(data))) 79 | b.ResetTimer() 80 | for i := 0; i < b.N; i++ { 81 | if _, err := w.Write(data); err != nil { 82 | b.Fatal(err) 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/testing/data/dockerfile.tar: -------------------------------------------------------------------------------- 1 | Dockerfile000644 000766 000024 00000001225 12327754570 013535 0ustar00tarsisstaff000000 000000 # this file describes how to build tsuru python image 2 | # to run it: 3 | # 1- install docker 4 | # 2- run: $ docker build -t tsuru/python https://raw.github.com/tsuru/basebuilder/master/python/Dockerfile 5 | 6 | from base:ubuntu-quantal 7 | run apt-get install wget -y --force-yes 8 | run wget http://github.com/tsuru/basebuilder/tarball/master -O basebuilder.tar.gz --no-check-certificate 9 | run mkdir /var/lib/tsuru 10 | run tar -xvf basebuilder.tar.gz -C /var/lib/tsuru --strip 1 11 | run cp /var/lib/tsuru/python/deploy /var/lib/tsuru 12 | run cp /var/lib/tsuru/base/restart /var/lib/tsuru 13 | run cp /var/lib/tsuru/base/start /var/lib/tsuru 14 | run /var/lib/tsuru/base/install 15 | run /var/lib/tsuru/base/setup 16 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/wrap_test.go: -------------------------------------------------------------------------------- 1 | package archive 2 | 3 | import ( 4 | "archive/tar" 5 | "bytes" 6 | "io" 7 | "testing" 8 | ) 9 | 10 | func TestGenerateEmptyFile(t *testing.T) { 11 | archive, err := Generate("emptyFile") 12 | if err != nil { 13 | t.Fatal(err) 14 | } 15 | if archive == nil { 16 | t.Fatal("The generated archive should not be nil.") 17 | } 18 | 19 | expectedFiles := [][]string{ 20 | {"emptyFile", ""}, 21 | } 22 | 23 | tr := tar.NewReader(archive) 24 | actualFiles := make([][]string, 0, 10) 25 | i := 0 26 | for { 27 | hdr, err := tr.Next() 28 | if err == io.EOF { 29 | break 30 | } 31 | if err != nil { 32 | t.Fatal(err) 33 | } 34 | buf := new(bytes.Buffer) 35 | buf.ReadFrom(tr) 36 | content := buf.String() 37 | actualFiles = append(actualFiles, []string{hdr.Name, content}) 38 | i++ 39 | } 40 | if len(actualFiles) != len(expectedFiles) { 41 | t.Fatalf("Number of expected file %d, got %d.", len(expectedFiles), len(actualFiles)) 42 | } 43 | for i := 0; i < len(expectedFiles); i++ { 44 | actual := actualFiles[i] 45 | expected := expectedFiles[i] 46 | if actual[0] != expected[0] { 47 | t.Fatalf("Expected name '%s', Actual name '%s'", expected[0], actual[0]) 48 | } 49 | if actual[1] != expected[1] { 50 | t.Fatalf("Expected content '%s', Actual content '%s'", expected[1], actual[1]) 51 | } 52 | } 53 | } 54 | 55 | func TestGenerateWithContent(t *testing.T) { 56 | archive, err := Generate("file", "content") 57 | if err != nil { 58 | t.Fatal(err) 59 | } 60 | if archive == nil { 61 | t.Fatal("The generated archive should not be nil.") 62 | } 63 | 64 | expectedFiles := [][]string{ 65 | {"file", "content"}, 66 | } 67 | 68 | tr := tar.NewReader(archive) 69 | actualFiles := make([][]string, 0, 10) 70 | i := 0 71 | for { 72 | hdr, err := tr.Next() 73 | if err == io.EOF { 74 | break 75 | } 76 | if err != nil { 77 | t.Fatal(err) 78 | } 79 | buf := new(bytes.Buffer) 80 | buf.ReadFrom(tr) 81 | content := buf.String() 82 | actualFiles = append(actualFiles, []string{hdr.Name, content}) 83 | i++ 84 | } 85 | if len(actualFiles) != len(expectedFiles) { 86 | t.Fatalf("Number of expected file %d, got %d.", len(expectedFiles), len(actualFiles)) 87 | } 88 | for i := 0; i < len(expectedFiles); i++ { 89 | actual := actualFiles[i] 90 | expected := expectedFiles[i] 91 | if actual[0] != expected[0] { 92 | t.Fatalf("Expected name '%s', Actual name '%s'", expected[0], actual[0]) 93 | } 94 | if actual[1] != expected[1] { 95 | t.Fatalf("Expected content '%s', Actual content '%s'", expected[1], actual[1]) 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/codegangsta/cli/cli_test.go: -------------------------------------------------------------------------------- 1 | package cli_test 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/codegangsta/cli" 7 | ) 8 | 9 | func Example() { 10 | app := cli.NewApp() 11 | app.Name = "todo" 12 | app.Usage = "task list on the command line" 13 | app.Commands = []cli.Command{ 14 | { 15 | Name: "add", 16 | ShortName: "a", 17 | Usage: "add a task to the list", 18 | Action: func(c *cli.Context) { 19 | println("added task: ", c.Args().First()) 20 | }, 21 | }, 22 | { 23 | Name: "complete", 24 | ShortName: "c", 25 | Usage: "complete a task on the list", 26 | Action: func(c *cli.Context) { 27 | println("completed task: ", c.Args().First()) 28 | }, 29 | }, 30 | } 31 | 32 | app.Run(os.Args) 33 | } 34 | 35 | func ExampleSubcommand() { 36 | app := cli.NewApp() 37 | app.Name = "say" 38 | app.Commands = []cli.Command{ 39 | { 40 | Name: "hello", 41 | ShortName: "hi", 42 | Usage: "use it to see a description", 43 | Description: "This is how we describe hello the function", 44 | Subcommands: []cli.Command{ 45 | { 46 | Name: "english", 47 | ShortName: "en", 48 | Usage: "sends a greeting in english", 49 | Description: "greets someone in english", 50 | Flags: []cli.Flag{ 51 | cli.StringFlag{ 52 | Name: "name", 53 | Value: "Bob", 54 | Usage: "Name of the person to greet", 55 | }, 56 | }, 57 | Action: func(c *cli.Context) { 58 | println("Hello, ", c.String("name")) 59 | }, 60 | }, { 61 | Name: "spanish", 62 | ShortName: "sp", 63 | Usage: "sends a greeting in spanish", 64 | Flags: []cli.Flag{ 65 | cli.StringFlag{ 66 | Name: "surname", 67 | Value: "Jones", 68 | Usage: "Surname of the person to greet", 69 | }, 70 | }, 71 | Action: func(c *cli.Context) { 72 | println("Hola, ", c.String("surname")) 73 | }, 74 | }, { 75 | Name: "french", 76 | ShortName: "fr", 77 | Usage: "sends a greeting in french", 78 | Flags: []cli.Flag{ 79 | cli.StringFlag{ 80 | Name: "nickname", 81 | Value: "Stevie", 82 | Usage: "Nickname of the person to greet", 83 | }, 84 | }, 85 | Action: func(c *cli.Context) { 86 | println("Bonjour, ", c.String("nickname")) 87 | }, 88 | }, 89 | }, 90 | }, { 91 | Name: "bye", 92 | Usage: "says goodbye", 93 | Action: func(c *cli.Context) { 94 | println("bye") 95 | }, 96 | }, 97 | } 98 | 99 | app.Run(os.Args) 100 | } 101 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/quipo/statsd/event/precisiontiming.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // PrecisionTiming keeps min/max/avg information about a timer over a certain interval 9 | type PrecisionTiming struct { 10 | Name string 11 | Min time.Duration 12 | Max time.Duration 13 | Value time.Duration 14 | Count int64 15 | } 16 | 17 | // NewPrecisionTiming is a factory for a Timing event, setting the Count to 1 to prevent div_by_0 errors 18 | func NewPrecisionTiming(k string, delta time.Duration) *PrecisionTiming { 19 | return &PrecisionTiming{Name: k, Min: delta, Max: delta, Value: delta, Count: 1} 20 | } 21 | 22 | // Update the event with metrics coming from a new one of the same type and with the same key 23 | func (e *PrecisionTiming) Update(e2 Event) error { 24 | if e.Type() != e2.Type() { 25 | return fmt.Errorf("statsd event type conflict: %s vs %s ", e.String(), e2.String()) 26 | } 27 | p := e2.Payload().(PrecisionTiming) 28 | e.Count += p.Count 29 | e.Value += p.Value 30 | e.Min = time.Duration(minInt64(int64(e.Min), int64(p.Min))) 31 | e.Max = time.Duration(maxInt64(int64(e.Max), int64(p.Min))) 32 | return nil 33 | } 34 | 35 | // Payload returns the aggregated value for this event 36 | func (e PrecisionTiming) Payload() interface{} { 37 | return e 38 | } 39 | 40 | // Stats returns an array of StatsD events as they travel over UDP 41 | func (e PrecisionTiming) Stats() []string { 42 | return []string{ 43 | fmt.Sprintf("%s.count:%d|a", e.Name, e.Count), 44 | fmt.Sprintf("%s.avg:%.6f|ms", e.Name, float64(int64(e.Value)/e.Count)/1000000), // make sure e.Count != 0 45 | fmt.Sprintf("%s.min:%.6f|ms", e.Name, e.durationToMs(e.Min)), 46 | fmt.Sprintf("%s.max:%.6f|ms", e.Name, e.durationToMs(e.Max)), 47 | } 48 | } 49 | 50 | // durationToMs converts time.Duration into the corresponding value in milliseconds 51 | func (e PrecisionTiming) durationToMs(x time.Duration) float64 { 52 | return float64(x) / float64(time.Millisecond) 53 | } 54 | 55 | // Key returns the name of this metric 56 | func (e PrecisionTiming) Key() string { 57 | return e.Name 58 | } 59 | 60 | // SetKey sets the name of this metric 61 | func (e *PrecisionTiming) SetKey(key string) { 62 | e.Name = key 63 | } 64 | 65 | // Type returns an integer identifier for this type of metric 66 | func (e PrecisionTiming) Type() int { 67 | return EventPrecisionTiming 68 | } 69 | 70 | // TypeString returns a name for this type of metric 71 | func (e PrecisionTiming) TypeString() string { 72 | return "PrecisionTiming" 73 | } 74 | 75 | // String returns a debug-friendly representation of this metric 76 | func (e PrecisionTiming) String() string { 77 | return fmt.Sprintf("{Type: %s, Key: %s, Value: %+v}", e.TypeString(), e.Name, e.Payload()) 78 | } 79 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/README.markdown: -------------------------------------------------------------------------------- 1 | # go-dockerclient 2 | 3 | [![Drone](https://drone.io/github.com/fsouza/go-dockerclient/status.png)](https://drone.io/github.com/fsouza/go-dockerclient/latest) 4 | [![Travis](https://img.shields.io/travis/fsouza/go-dockerclient.svg?style=flat-square)](https://travis-ci.org/fsouza/go-dockerclient) 5 | [![GoDoc](https://img.shields.io/badge/api-Godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/fsouza/go-dockerclient) 6 | 7 | This package presents a client for the Docker remote API. It also provides 8 | support for the extensions in the [Swarm API](https://docs.docker.com/swarm/API/). 9 | 10 | For more details, check the [remote API documentation](http://docs.docker.com/en/latest/reference/api/docker_remote_api/). 11 | 12 | ## Example 13 | 14 | ```go 15 | package main 16 | 17 | import ( 18 | "fmt" 19 | 20 | "github.com/fsouza/go-dockerclient" 21 | ) 22 | 23 | func main() { 24 | endpoint := "unix:///var/run/docker.sock" 25 | client, _ := docker.NewClient(endpoint) 26 | imgs, _ := client.ListImages(docker.ListImagesOptions{All: false}) 27 | for _, img := range imgs { 28 | fmt.Println("ID: ", img.ID) 29 | fmt.Println("RepoTags: ", img.RepoTags) 30 | fmt.Println("Created: ", img.Created) 31 | fmt.Println("Size: ", img.Size) 32 | fmt.Println("VirtualSize: ", img.VirtualSize) 33 | fmt.Println("ParentId: ", img.ParentID) 34 | } 35 | } 36 | ``` 37 | 38 | ## Using with Boot2Docker 39 | 40 | Boot2Docker runs Docker with TLS enabled. In order to instantiate the client you should use NewTLSClient, passing the endpoint and path for key and certificates as parameters. 41 | 42 | For more details about TLS support in Boot2Docker, please refer to [TLS support](https://github.com/boot2docker/boot2docker#tls-support) on Boot2Docker's readme. 43 | 44 | ```go 45 | package main 46 | 47 | import ( 48 | "fmt" 49 | 50 | "github.com/fsouza/go-dockerclient" 51 | ) 52 | 53 | func main() { 54 | endpoint := "tcp://[ip]:[port]" 55 | path := os.Getenv("DOCKER_CERT_PATH") 56 | ca := fmt.Sprintf("%s/ca.pem", path) 57 | cert := fmt.Sprintf("%s/cert.pem", path) 58 | key := fmt.Sprintf("%s/key.pem", path) 59 | client, _ := docker.NewTLSClient(endpoint, cert, key, ca) 60 | // use client 61 | } 62 | ``` 63 | 64 | ## Developing 65 | 66 | All development commands can be seen in the [Makefile](Makefile). 67 | 68 | Commited code must pass: 69 | 70 | * [golint](https://github.com/golang/lint) 71 | * [go vet](https://godoc.org/golang.org/x/tools/cmd/vet) 72 | * [gofmt](https://golang.org/cmd/gofmt) 73 | * [go test](https://golang.org/cmd/go/#hdr-Test_packages) 74 | 75 | Running `make test` will check all of these. If your editor does not automatically call gofmt, `make fmt` will format all go files in this repository. 76 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/auth.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package docker 6 | 7 | import ( 8 | "encoding/base64" 9 | "encoding/json" 10 | "io" 11 | "os" 12 | "path" 13 | "strings" 14 | ) 15 | 16 | // AuthConfiguration represents authentication options to use in the PushImage 17 | // method. It represents the authentication in the Docker index server. 18 | type AuthConfiguration struct { 19 | Username string `json:"username,omitempty"` 20 | Password string `json:"password,omitempty"` 21 | Email string `json:"email,omitempty"` 22 | ServerAddress string `json:"serveraddress,omitempty"` 23 | } 24 | 25 | // AuthConfigurations represents authentication options to use for the 26 | // PushImage method accommodating the new X-Registry-Config header 27 | type AuthConfigurations struct { 28 | Configs map[string]AuthConfiguration `json:"configs"` 29 | } 30 | 31 | // dockerConfig represents a registry authentation configuration from the 32 | // .dockercfg file. 33 | type dockerConfig struct { 34 | Auth string `json:"auth"` 35 | Email string `json:"email"` 36 | } 37 | 38 | // NewAuthConfigurationsFromDockerCfg returns AuthConfigurations from the 39 | // ~/.dockercfg file. 40 | func NewAuthConfigurationsFromDockerCfg() (*AuthConfigurations, error) { 41 | p := path.Join(os.Getenv("HOME"), ".dockercfg") 42 | r, err := os.Open(p) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return NewAuthConfigurations(r) 47 | } 48 | 49 | // NewAuthConfigurations returns AuthConfigurations from a JSON encoded string in the 50 | // same format as the .dockercfg file. 51 | func NewAuthConfigurations(r io.Reader) (*AuthConfigurations, error) { 52 | var auth *AuthConfigurations 53 | var confs map[string]dockerConfig 54 | if err := json.NewDecoder(r).Decode(&confs); err != nil { 55 | return nil, err 56 | } 57 | auth, err := authConfigs(confs) 58 | if err != nil { 59 | return nil, err 60 | } 61 | return auth, nil 62 | } 63 | 64 | // authConfigs converts a dockerConfigs map to a AuthConfigurations object. 65 | func authConfigs(confs map[string]dockerConfig) (*AuthConfigurations, error) { 66 | c := &AuthConfigurations{ 67 | Configs: make(map[string]AuthConfiguration), 68 | } 69 | for reg, conf := range confs { 70 | data, err := base64.StdEncoding.DecodeString(conf.Auth) 71 | if err != nil { 72 | return nil, err 73 | } 74 | userpass := strings.Split(string(data), ":") 75 | c.Configs[reg] = AuthConfiguration{ 76 | Email: conf.Email, 77 | Username: userpass[0], 78 | Password: userpass[1], 79 | ServerAddress: reg, 80 | } 81 | } 82 | return c, nil 83 | } 84 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/units/size.go: -------------------------------------------------------------------------------- 1 | package units 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | // See: http://en.wikipedia.org/wiki/Binary_prefix 11 | const ( 12 | // Decimal 13 | 14 | KB = 1000 15 | MB = 1000 * KB 16 | GB = 1000 * MB 17 | TB = 1000 * GB 18 | PB = 1000 * TB 19 | 20 | // Binary 21 | 22 | KiB = 1024 23 | MiB = 1024 * KiB 24 | GiB = 1024 * MiB 25 | TiB = 1024 * GiB 26 | PiB = 1024 * TiB 27 | ) 28 | 29 | type unitMap map[string]int64 30 | 31 | var ( 32 | decimalMap = unitMap{"k": KB, "m": MB, "g": GB, "t": TB, "p": PB} 33 | binaryMap = unitMap{"k": KiB, "m": MiB, "g": GiB, "t": TiB, "p": PiB} 34 | sizeRegex = regexp.MustCompile(`^(\d+)([kKmMgGtTpP])?[bB]?$`) 35 | ) 36 | 37 | var decimapAbbrs = []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} 38 | var binaryAbbrs = []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} 39 | 40 | // CustomSize returns a human-readable approximation of a size 41 | // using custom format 42 | func CustomSize(format string, size float64, base float64, _map []string) string { 43 | i := 0 44 | for size >= base { 45 | size = size / base 46 | i++ 47 | } 48 | return fmt.Sprintf(format, size, _map[i]) 49 | } 50 | 51 | // HumanSize returns a human-readable approximation of a size 52 | // using SI standard (eg. "44kB", "17MB") 53 | func HumanSize(size float64) string { 54 | return CustomSize("%.4g %s", float64(size), 1000.0, decimapAbbrs) 55 | } 56 | 57 | func BytesSize(size float64) string { 58 | return CustomSize("%.4g %s", size, 1024.0, binaryAbbrs) 59 | } 60 | 61 | // FromHumanSize returns an integer from a human-readable specification of a 62 | // size using SI standard (eg. "44kB", "17MB") 63 | func FromHumanSize(size string) (int64, error) { 64 | return parseSize(size, decimalMap) 65 | } 66 | 67 | // RAMInBytes parses a human-readable string representing an amount of RAM 68 | // in bytes, kibibytes, mebibytes, gibibytes, or tebibytes and 69 | // returns the number of bytes, or -1 if the string is unparseable. 70 | // Units are case-insensitive, and the 'b' suffix is optional. 71 | func RAMInBytes(size string) (int64, error) { 72 | return parseSize(size, binaryMap) 73 | } 74 | 75 | // Parses the human-readable size string into the amount it represents 76 | func parseSize(sizeStr string, uMap unitMap) (int64, error) { 77 | matches := sizeRegex.FindStringSubmatch(sizeStr) 78 | if len(matches) != 3 { 79 | return -1, fmt.Errorf("invalid size: '%s'", sizeStr) 80 | } 81 | 82 | size, err := strconv.ParseInt(matches[1], 10, 0) 83 | if err != nil { 84 | return -1, err 85 | } 86 | 87 | unitPrefix := strings.ToLower(matches[2]) 88 | if mul, ok := uMap[unitPrefix]; ok { 89 | size *= mul 90 | } 91 | 92 | return size, nil 93 | } 94 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive/example_changes.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Simple tool to create an archive stream from an old and new directory 4 | // 5 | // By default it will stream the comparison of two temporary directories with junk files 6 | package main 7 | 8 | import ( 9 | "flag" 10 | "fmt" 11 | "io" 12 | "io/ioutil" 13 | "os" 14 | "path" 15 | 16 | "github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus" 17 | "github.com/fsouza/go-dockerclient/vendor/github.com/docker/docker/pkg/archive" 18 | ) 19 | 20 | var ( 21 | flDebug = flag.Bool("D", false, "debugging output") 22 | flNewDir = flag.String("newdir", "", "") 23 | flOldDir = flag.String("olddir", "", "") 24 | log = logrus.New() 25 | ) 26 | 27 | func main() { 28 | flag.Usage = func() { 29 | fmt.Println("Produce a tar from comparing two directory paths. By default a demo tar is created of around 200 files (including hardlinks)") 30 | fmt.Printf("%s [OPTIONS]\n", os.Args[0]) 31 | flag.PrintDefaults() 32 | } 33 | flag.Parse() 34 | log.Out = os.Stderr 35 | if (len(os.Getenv("DEBUG")) > 0) || *flDebug { 36 | logrus.SetLevel(logrus.DebugLevel) 37 | } 38 | var newDir, oldDir string 39 | 40 | if len(*flNewDir) == 0 { 41 | var err error 42 | newDir, err = ioutil.TempDir("", "docker-test-newDir") 43 | if err != nil { 44 | log.Fatal(err) 45 | } 46 | defer os.RemoveAll(newDir) 47 | if _, err := prepareUntarSourceDirectory(100, newDir, true); err != nil { 48 | log.Fatal(err) 49 | } 50 | } else { 51 | newDir = *flNewDir 52 | } 53 | 54 | if len(*flOldDir) == 0 { 55 | oldDir, err := ioutil.TempDir("", "docker-test-oldDir") 56 | if err != nil { 57 | log.Fatal(err) 58 | } 59 | defer os.RemoveAll(oldDir) 60 | } else { 61 | oldDir = *flOldDir 62 | } 63 | 64 | changes, err := archive.ChangesDirs(newDir, oldDir) 65 | if err != nil { 66 | log.Fatal(err) 67 | } 68 | 69 | a, err := archive.ExportChanges(newDir, changes) 70 | if err != nil { 71 | log.Fatal(err) 72 | } 73 | defer a.Close() 74 | 75 | i, err := io.Copy(os.Stdout, a) 76 | if err != nil && err != io.EOF { 77 | log.Fatal(err) 78 | } 79 | fmt.Fprintf(os.Stderr, "wrote archive of %d bytes", i) 80 | } 81 | 82 | func prepareUntarSourceDirectory(numberOfFiles int, targetPath string, makeLinks bool) (int, error) { 83 | fileData := []byte("fooo") 84 | for n := 0; n < numberOfFiles; n++ { 85 | fileName := fmt.Sprintf("file-%d", n) 86 | if err := ioutil.WriteFile(path.Join(targetPath, fileName), fileData, 0700); err != nil { 87 | return 0, err 88 | } 89 | if makeLinks { 90 | if err := os.Link(path.Join(targetPath, fileName), path.Join(targetPath, fileName+"-link")); err != nil { 91 | return 0, err 92 | } 93 | } 94 | } 95 | totalSize := numberOfFiles * len(fileData) 96 | return totalSize, nil 97 | } 98 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/tls.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 go-dockerclient authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // The content is borrowed from Docker's own source code to provide a simple 6 | // tls based dialer 7 | 8 | package docker 9 | 10 | import ( 11 | "crypto/tls" 12 | "errors" 13 | "net" 14 | "strings" 15 | "time" 16 | ) 17 | 18 | type tlsClientCon struct { 19 | *tls.Conn 20 | rawConn net.Conn 21 | } 22 | 23 | func (c *tlsClientCon) CloseWrite() error { 24 | // Go standard tls.Conn doesn't provide the CloseWrite() method so we do it 25 | // on its underlying connection. 26 | if cwc, ok := c.rawConn.(interface { 27 | CloseWrite() error 28 | }); ok { 29 | return cwc.CloseWrite() 30 | } 31 | return nil 32 | } 33 | 34 | func tlsDialWithDialer(dialer *net.Dialer, network, addr string, config *tls.Config) (net.Conn, error) { 35 | // We want the Timeout and Deadline values from dialer to cover the 36 | // whole process: TCP connection and TLS handshake. This means that we 37 | // also need to start our own timers now. 38 | timeout := dialer.Timeout 39 | 40 | if !dialer.Deadline.IsZero() { 41 | deadlineTimeout := dialer.Deadline.Sub(time.Now()) 42 | if timeout == 0 || deadlineTimeout < timeout { 43 | timeout = deadlineTimeout 44 | } 45 | } 46 | 47 | var errChannel chan error 48 | 49 | if timeout != 0 { 50 | errChannel = make(chan error, 2) 51 | time.AfterFunc(timeout, func() { 52 | errChannel <- errors.New("") 53 | }) 54 | } 55 | 56 | rawConn, err := dialer.Dial(network, addr) 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | colonPos := strings.LastIndex(addr, ":") 62 | if colonPos == -1 { 63 | colonPos = len(addr) 64 | } 65 | hostname := addr[:colonPos] 66 | 67 | // If no ServerName is set, infer the ServerName 68 | // from the hostname we're connecting to. 69 | if config.ServerName == "" { 70 | // Make a copy to avoid polluting argument or default. 71 | c := *config 72 | c.ServerName = hostname 73 | config = &c 74 | } 75 | 76 | conn := tls.Client(rawConn, config) 77 | 78 | if timeout == 0 { 79 | err = conn.Handshake() 80 | } else { 81 | go func() { 82 | errChannel <- conn.Handshake() 83 | }() 84 | 85 | err = <-errChannel 86 | } 87 | 88 | if err != nil { 89 | rawConn.Close() 90 | return nil, err 91 | } 92 | 93 | // This is Docker difference with standard's crypto/tls package: returned a 94 | // wrapper which holds both the TLS and raw connections. 95 | return &tlsClientCon{conn, rawConn}, nil 96 | } 97 | 98 | func tlsDial(network, addr string, config *tls.Config) (net.Conn, error) { 99 | return tlsDialWithDialer(new(net.Dialer), network, addr, config) 100 | } 101 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Fields type, used to pass to `WithFields`. 9 | type Fields map[string]interface{} 10 | 11 | // Level type 12 | type Level uint8 13 | 14 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 15 | func (level Level) String() string { 16 | switch level { 17 | case DebugLevel: 18 | return "debug" 19 | case InfoLevel: 20 | return "info" 21 | case WarnLevel: 22 | return "warning" 23 | case ErrorLevel: 24 | return "error" 25 | case FatalLevel: 26 | return "fatal" 27 | case PanicLevel: 28 | return "panic" 29 | } 30 | 31 | return "unknown" 32 | } 33 | 34 | // ParseLevel takes a string level and returns the Logrus log level constant. 35 | func ParseLevel(lvl string) (Level, error) { 36 | switch lvl { 37 | case "panic": 38 | return PanicLevel, nil 39 | case "fatal": 40 | return FatalLevel, nil 41 | case "error": 42 | return ErrorLevel, nil 43 | case "warn", "warning": 44 | return WarnLevel, nil 45 | case "info": 46 | return InfoLevel, nil 47 | case "debug": 48 | return DebugLevel, nil 49 | } 50 | 51 | var l Level 52 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 53 | } 54 | 55 | // These are the different logging levels. You can set the logging level to log 56 | // on your instance of logger, obtained with `logrus.New()`. 57 | const ( 58 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 59 | // message passed to Debug, Info, ... 60 | PanicLevel Level = iota 61 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 62 | // logging level is set to Panic. 63 | FatalLevel 64 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 65 | // Commonly used for hooks to send errors to an error tracking service. 66 | ErrorLevel 67 | // WarnLevel level. Non-critical entries that deserve eyes. 68 | WarnLevel 69 | // InfoLevel level. General operational entries about what's going on inside the 70 | // application. 71 | InfoLevel 72 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 73 | DebugLevel 74 | ) 75 | 76 | // Won't compile if StdLogger can't be realized by a log.Logger 77 | var _ StdLogger = &log.Logger{} 78 | 79 | // StdLogger is what your logrus-enabled library should take, that way 80 | // it'll accept a stdlib logger and a logrus logger. There's no standard 81 | // interface, this is the closest we get, unfortunately. 82 | type StdLogger interface { 83 | Print(...interface{}) 84 | Printf(string, ...interface{}) 85 | Println(...interface{}) 86 | 87 | Fatal(...interface{}) 88 | Fatalf(string, ...interface{}) 89 | Fatalln(...interface{}) 90 | 91 | Panic(...interface{}) 92 | Panicf(string, ...interface{}) 93 | Panicln(...interface{}) 94 | } 95 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/gorilla/context/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package context stores values shared during a request lifetime. 7 | 8 | For example, a router can set variables extracted from the URL and later 9 | application handlers can access those values, or it can be used to store 10 | sessions values to be saved at the end of a request. There are several 11 | others common uses. 12 | 13 | The idea was posted by Brad Fitzpatrick to the go-nuts mailing list: 14 | 15 | http://groups.google.com/group/golang-nuts/msg/e2d679d303aa5d53 16 | 17 | Here's the basic usage: first define the keys that you will need. The key 18 | type is interface{} so a key can be of any type that supports equality. 19 | Here we define a key using a custom int type to avoid name collisions: 20 | 21 | package foo 22 | 23 | import ( 24 | "github.com/gorilla/context" 25 | ) 26 | 27 | type key int 28 | 29 | const MyKey key = 0 30 | 31 | Then set a variable. Variables are bound to an http.Request object, so you 32 | need a request instance to set a value: 33 | 34 | context.Set(r, MyKey, "bar") 35 | 36 | The application can later access the variable using the same key you provided: 37 | 38 | func MyHandler(w http.ResponseWriter, r *http.Request) { 39 | // val is "bar". 40 | val := context.Get(r, foo.MyKey) 41 | 42 | // returns ("bar", true) 43 | val, ok := context.GetOk(r, foo.MyKey) 44 | // ... 45 | } 46 | 47 | And that's all about the basic usage. We discuss some other ideas below. 48 | 49 | Any type can be stored in the context. To enforce a given type, make the key 50 | private and wrap Get() and Set() to accept and return values of a specific 51 | type: 52 | 53 | type key int 54 | 55 | const mykey key = 0 56 | 57 | // GetMyKey returns a value for this package from the request values. 58 | func GetMyKey(r *http.Request) SomeType { 59 | if rv := context.Get(r, mykey); rv != nil { 60 | return rv.(SomeType) 61 | } 62 | return nil 63 | } 64 | 65 | // SetMyKey sets a value for this package in the request values. 66 | func SetMyKey(r *http.Request, val SomeType) { 67 | context.Set(r, mykey, val) 68 | } 69 | 70 | Variables must be cleared at the end of a request, to remove all values 71 | that were stored. This can be done in an http.Handler, after a request was 72 | served. Just call Clear() passing the request: 73 | 74 | context.Clear(r) 75 | 76 | ...or use ClearHandler(), which conveniently wraps an http.Handler to clear 77 | variables at the end of a request lifetime. 78 | 79 | The Routers from the packages gorilla/mux and gorilla/pat call Clear() 80 | so if you are using either of them you don't need to clear the context manually. 81 | */ 82 | package context 83 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/hook_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/fsouza/go-dockerclient/vendor/github.com/stretchr/testify/assert" 7 | ) 8 | 9 | type TestHook struct { 10 | Fired bool 11 | } 12 | 13 | func (hook *TestHook) Fire(entry *Entry) error { 14 | hook.Fired = true 15 | return nil 16 | } 17 | 18 | func (hook *TestHook) Levels() []Level { 19 | return []Level{ 20 | DebugLevel, 21 | InfoLevel, 22 | WarnLevel, 23 | ErrorLevel, 24 | FatalLevel, 25 | PanicLevel, 26 | } 27 | } 28 | 29 | func TestHookFires(t *testing.T) { 30 | hook := new(TestHook) 31 | 32 | LogAndAssertJSON(t, func(log *Logger) { 33 | log.Hooks.Add(hook) 34 | assert.Equal(t, hook.Fired, false) 35 | 36 | log.Print("test") 37 | }, func(fields Fields) { 38 | assert.Equal(t, hook.Fired, true) 39 | }) 40 | } 41 | 42 | type ModifyHook struct { 43 | } 44 | 45 | func (hook *ModifyHook) Fire(entry *Entry) error { 46 | entry.Data["wow"] = "whale" 47 | return nil 48 | } 49 | 50 | func (hook *ModifyHook) Levels() []Level { 51 | return []Level{ 52 | DebugLevel, 53 | InfoLevel, 54 | WarnLevel, 55 | ErrorLevel, 56 | FatalLevel, 57 | PanicLevel, 58 | } 59 | } 60 | 61 | func TestHookCanModifyEntry(t *testing.T) { 62 | hook := new(ModifyHook) 63 | 64 | LogAndAssertJSON(t, func(log *Logger) { 65 | log.Hooks.Add(hook) 66 | log.WithField("wow", "elephant").Print("test") 67 | }, func(fields Fields) { 68 | assert.Equal(t, fields["wow"], "whale") 69 | }) 70 | } 71 | 72 | func TestCanFireMultipleHooks(t *testing.T) { 73 | hook1 := new(ModifyHook) 74 | hook2 := new(TestHook) 75 | 76 | LogAndAssertJSON(t, func(log *Logger) { 77 | log.Hooks.Add(hook1) 78 | log.Hooks.Add(hook2) 79 | 80 | log.WithField("wow", "elephant").Print("test") 81 | }, func(fields Fields) { 82 | assert.Equal(t, fields["wow"], "whale") 83 | assert.Equal(t, hook2.Fired, true) 84 | }) 85 | } 86 | 87 | type ErrorHook struct { 88 | Fired bool 89 | } 90 | 91 | func (hook *ErrorHook) Fire(entry *Entry) error { 92 | hook.Fired = true 93 | return nil 94 | } 95 | 96 | func (hook *ErrorHook) Levels() []Level { 97 | return []Level{ 98 | ErrorLevel, 99 | } 100 | } 101 | 102 | func TestErrorHookShouldntFireOnInfo(t *testing.T) { 103 | hook := new(ErrorHook) 104 | 105 | LogAndAssertJSON(t, func(log *Logger) { 106 | log.Hooks.Add(hook) 107 | log.Info("test") 108 | }, func(fields Fields) { 109 | assert.Equal(t, hook.Fired, false) 110 | }) 111 | } 112 | 113 | func TestErrorHookShouldFireOnError(t *testing.T) { 114 | hook := new(ErrorHook) 115 | 116 | LogAndAssertJSON(t, func(log *Logger) { 117 | log.Hooks.Add(hook) 118 | log.Error("test") 119 | }, func(fields Fields) { 120 | assert.Equal(t, hook.Fired, true) 121 | }) 122 | } 123 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dockerstats 2 | 3 | Dockerstats is a simple docker container for collecting metrics from the [Docker Stats](https://docs.docker.com/reference/api/docker_remote_api_v1.17/#get-container-stats-based-on-resource-usage) API and sending them elsewhere. It supports adapters for configuring where you want metrics to be sent. It's heavily inspired by [logspout](https://github.com/gliderlabs/logspout) and is roughly similar to [cadvisor](https://github.com/google/cadvisor) but simpler. 4 | 5 | Currently, the following adapters are provided: 6 | 7 | * **Log**: An adapter that logs stats to stdout. This adapter can be useful if you're already using something like [logspout](https://github.com/gliderlabs/logspout) to collect logs from containers. The format can be configured via the `STAT_TEMPLATE` environment variable. The default template is a template that will log stats in [l2met](https://github.com/ryandotsmith/l2met/wiki/Usage#logging-convention) format. Here's an [example](https://gist.github.com/ejholmes/c56a15b7d760389f041c) set of metrics with the default template. 8 | * **Statsd**: _TODO_ 9 | * **Librato**: _TODO_ 10 | 11 | ## Usage 12 | 13 | Simply run the container and mount the docker socket: 14 | 15 | ```console 16 | $ docker run --name="dockerstats" \ 17 | --volume=/var/run/docker.sock:/tmp/docker.sock \ 18 | remind101/dockerstats 19 | ``` 20 | 21 | ## Metrics 22 | 23 | The following metrics will be created: 24 | 25 | ``` 26 | Network.RxDropped 27 | Network.RxBytes 28 | Network.RxErrors 29 | Network.TxPackets 30 | Network.RxPackets 31 | Network.TxErrors 32 | Network.TxBytes 33 | 34 | MemoryStats.Stats.TotalPgmafault 35 | MemoryStats.Stats.Cache 36 | MemoryStats.Stats.MappedFile 37 | MemoryStats.Stats.TotalInactiveFile 38 | MemoryStats.Stats.Pgpgout 39 | MemoryStats.Stats.Rss 40 | MemoryStats.Stats.TotalMappedFile 41 | MemoryStats.Stats.Writeback 42 | MemoryStats.Stats.Unevictable 43 | MemoryStats.Stats.Pgpgin 44 | MemoryStats.Stats.TotalUnevictable 45 | MemoryStats.Stats.Pgmajfault 46 | MemoryStats.Stats.TotalRss 47 | MemoryStats.Stats.TotalRssHuge 48 | MemoryStats.Stats.TotalWriteback 49 | MemoryStats.Stats.TotalInactiveAnon 50 | MemoryStats.Stats.RssHuge 51 | MemoryStats.Stats.HierarchicalMemoryLimit 52 | MemoryStats.Stats.TotalPgfault 53 | MemoryStats.Stats.TotalActiveFile 54 | MemoryStats.Stats.ActiveAnon 55 | MemoryStats.Stats.TotalActiveAnon 56 | MemoryStats.Stats.TotalPgpgout 57 | MemoryStats.Stats.TotalCache 58 | MemoryStats.Stats.InactiveAnon 59 | MemoryStats.Stats.ActiveFile 60 | MemoryStats.Stats.Pgfault 61 | MemoryStats.Stats.InactiveFile 62 | MemoryStats.Stats.TotalPgpgin 63 | MemoryStats.MaxUsage 64 | MemoryStats.Usage 65 | MemoryStats.Failcnt 66 | MemoryStats.Limit 67 | 68 | CPUStats.CPUUsage.UsageInUsermode 69 | CPUStats.CPUUsage.TotalUsage 70 | CPUStats.CPUUsage.UsageInKernelmode 71 | CPUStats.SystemCPUUsage 72 | CPUStats.ThrottlingData.Periods 73 | CPUStats.ThrottlingData.ThrottledPeriods 74 | CPUStats.ThrottlingData.ThrottledTime 75 | ``` 76 | 77 | ## Roadmap 78 | 79 | * Add a statsd drain. 80 | * BlkioStats 81 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/code.google.com/p/go-uuid/uuid/node.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Google Inc. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package uuid 6 | 7 | import "net" 8 | 9 | var ( 10 | interfaces []net.Interface // cached list of interfaces 11 | ifname string // name of interface being used 12 | nodeID []byte // hardware for version 1 UUIDs 13 | ) 14 | 15 | // NodeInterface returns the name of the interface from which the NodeID was 16 | // derived. The interface "user" is returned if the NodeID was set by 17 | // SetNodeID. 18 | func NodeInterface() string { 19 | return ifname 20 | } 21 | 22 | // SetNodeInterface selects the hardware address to be used for Version 1 UUIDs. 23 | // If name is "" then the first usable interface found will be used or a random 24 | // Node ID will be generated. If a named interface cannot be found then false 25 | // is returned. 26 | // 27 | // SetNodeInterface never fails when name is "". 28 | func SetNodeInterface(name string) bool { 29 | if interfaces == nil { 30 | var err error 31 | interfaces, err = net.Interfaces() 32 | if err != nil && name != "" { 33 | return false 34 | } 35 | } 36 | 37 | for _, ifs := range interfaces { 38 | if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) { 39 | if setNodeID(ifs.HardwareAddr) { 40 | ifname = ifs.Name 41 | return true 42 | } 43 | } 44 | } 45 | 46 | // We found no interfaces with a valid hardware address. If name 47 | // does not specify a specific interface generate a random Node ID 48 | // (section 4.1.6) 49 | if name == "" { 50 | if nodeID == nil { 51 | nodeID = make([]byte, 6) 52 | } 53 | randomBits(nodeID) 54 | return true 55 | } 56 | return false 57 | } 58 | 59 | // NodeID returns a slice of a copy of the current Node ID, setting the Node ID 60 | // if not already set. 61 | func NodeID() []byte { 62 | if nodeID == nil { 63 | SetNodeInterface("") 64 | } 65 | nid := make([]byte, 6) 66 | copy(nid, nodeID) 67 | return nid 68 | } 69 | 70 | // SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes 71 | // of id are used. If id is less than 6 bytes then false is returned and the 72 | // Node ID is not set. 73 | func SetNodeID(id []byte) bool { 74 | if setNodeID(id) { 75 | ifname = "user" 76 | return true 77 | } 78 | return false 79 | } 80 | 81 | func setNodeID(id []byte) bool { 82 | if len(id) < 6 { 83 | return false 84 | } 85 | if nodeID == nil { 86 | nodeID = make([]byte, 6) 87 | } 88 | copy(nodeID, id) 89 | return true 90 | } 91 | 92 | // NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is 93 | // not valid. The NodeID is only well defined for version 1 and 2 UUIDs. 94 | func (uuid UUID) NodeID() []byte { 95 | if len(uuid) != 16 { 96 | return nil 97 | } 98 | node := make([]byte, 6) 99 | copy(node, uuid[10:]) 100 | return node 101 | } 102 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of go-dockerclient authors for copyright purposes. 2 | 3 | Adam Bell-Hanssen 4 | Aldrin Leal 5 | Andreas Jaekle 6 | Andrews Medina 7 | Artem Sidorenko 8 | Andy Goldstein 9 | Ben Marini 10 | Ben McCann 11 | Brian Lalor 12 | Burke Libbey 13 | Carlos Diaz-Padron 14 | Cezar Sa Espinola 15 | Cheah Chu Yeow 16 | cheneydeng 17 | CMGS 18 | Daniel, Dao Quang Minh 19 | Darren Shepherd 20 | David Huie 21 | Dawn Chen 22 | Ed 23 | Eric Anderson 24 | Ewout Prangsma 25 | Fabio Rehm 26 | Fatih Arslan 27 | Flavia Missi 28 | Francisco Souza 29 | Guillermo Álvarez Fernández 30 | James Bardin 31 | Jari Kolehmainen 32 | Jason Wilder 33 | Jawher Moussa 34 | Jean-Baptiste Dalido 35 | Jeff Mitchell 36 | Jeffrey Hulten 37 | Johan Euphrosine 38 | Kamil Domanski 39 | Karan Misra 40 | Kim, Hirokuni 41 | Kyle Allan 42 | liron-l 43 | Lucas Clemente 44 | Lucas Weiblen 45 | Mantas Matelis 46 | Martin Sweeney 47 | Máximo Cuadros Ortiz 48 | Michal Fojtik 49 | Mike Dillon 50 | Mrunal Patel 51 | Nick Ethier 52 | Omeid Matten 53 | Paul Morie 54 | Paul Weil 55 | Peter Edge 56 | Peter Jihoon Kim 57 | Philippe Lafoucrière 58 | Rafe Colton 59 | Rob Miller 60 | Robert Williamson 61 | Salvador Gironès 62 | Sam Rijs 63 | Simon Eskildsen 64 | Simon Menke 65 | Skolos 66 | Soulou 67 | Sridhar Ratnakumar 68 | Summer Mousa 69 | Tarsis Azevedo 70 | Tim Schindler 71 | Tobi Knaup 72 | Victor Marmol 73 | Vincenzo Prignano 74 | Wiliam Souza 75 | Ye Yin 76 | Yuriy Bogdanov 77 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/hb_test.go: -------------------------------------------------------------------------------- 1 | package hb 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "fmt" 7 | "io/ioutil" 8 | "net/http" 9 | "net/http/httptest" 10 | "path" 11 | "testing" 12 | 13 | "github.com/remind101/pkg/reporter" 14 | "golang.org/x/net/context" 15 | ) 16 | 17 | var ( 18 | // boom 19 | errBoom = errors.New("boom") 20 | 21 | // boom with backtrace. 22 | errBoomMore = reporter.NewError(errBoom, 0) 23 | ) 24 | 25 | func TestSend(t *testing.T) { 26 | s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 27 | if got, want := r.Header.Get("X-Api-Key"), "1234"; got != want { 28 | t.Fatal("API Key => %s; want %s", got, want) 29 | } 30 | 31 | w.WriteHeader(200) 32 | })) 33 | defer s.Close() 34 | 35 | c := NewClientFromKey("1234") 36 | c.URL = s.URL 37 | r := &Reporter{ 38 | client: c, 39 | } 40 | 41 | if err := r.Report(context.Background(), reporter.NewError(errBoom, 0)); err != nil { 42 | t.Fatal(err) 43 | } 44 | } 45 | 46 | func TestNewReport(t *testing.T) { 47 | tests := []struct { 48 | err error 49 | fixture string 50 | 51 | // if set to true, removes environment specific information from 52 | // the backtrace. 53 | truncBacktrace bool 54 | }{ 55 | // With a basic error 56 | { 57 | err: errBoom, 58 | fixture: "boom.json", 59 | }, 60 | 61 | // With a typed error 62 | { 63 | err: &typedError{errBoom}, 64 | fixture: "boom-typed.json", 65 | }, 66 | 67 | // With a reporter.Error. 68 | { 69 | err: errBoomMore, 70 | fixture: "boom-more.json", 71 | truncBacktrace: true, 72 | }, 73 | 74 | // reporter.Error with contextual information. 75 | { 76 | err: &reporter.Error{ 77 | Err: errBoom, 78 | Context: map[string]interface{}{ 79 | "request_id": "1234", 80 | }, 81 | Request: func() *http.Request { 82 | req, _ := http.NewRequest("GET", "/api/foo", nil) 83 | req.Header.Set("Content-Type", "application/json") 84 | req.Header.Set("X-Forwarded-For", "127.0.0.1") 85 | req.SetBasicAuth("Foo", "bar") 86 | return req 87 | }(), 88 | }, 89 | fixture: "boom-request.json", 90 | }, 91 | } 92 | 93 | for i, tt := range tests { 94 | report := NewReport(tt.err) 95 | 96 | if tt.truncBacktrace { 97 | for _, line := range report.Error.Backtrace { 98 | line.File = fmt.Sprintf("(removed)/%s", path.Base(line.File)) 99 | line.Number = "(removed)" 100 | } 101 | } 102 | 103 | fixture := fmt.Sprintf("test-fixtures/%s", tt.fixture) 104 | 105 | f, err := ioutil.ReadFile(fixture) 106 | if err != nil { 107 | t.Fatal(err) 108 | } 109 | 110 | raw, err := json.MarshalIndent(report, "", " ") 111 | if err != nil { 112 | t.Fatal(err) 113 | } 114 | 115 | if got, want := string(raw), string(f); got != want { 116 | if err := ioutil.WriteFile(fixture, raw, 0644); err != nil { 117 | t.Fatal(err) 118 | } 119 | 120 | t.Errorf("#%d: Report => %v; want %v", i, got, want) 121 | } 122 | } 123 | } 124 | 125 | type typedError struct { 126 | error 127 | } 128 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/remind101/pkg/reporter/hb/hb.go: -------------------------------------------------------------------------------- 1 | // package hb is a Go package from sending errors to Honeybadger. 2 | package hb 3 | 4 | import ( 5 | "fmt" 6 | "os" 7 | "strings" 8 | 9 | "github.com/remind101/pkg/reporter" 10 | "github.com/remind101/pkg/reporter/util" 11 | "golang.org/x/net/context" 12 | ) 13 | 14 | // Ensure that Reporter implements the reporter.Reporter interface. 15 | var _ reporter.Reporter = &Reporter{} 16 | 17 | // Headers that won't be sent to honeybadger. 18 | var IgnoredHeaders = map[string]struct{}{ 19 | "Authorization": struct{}{}, 20 | } 21 | 22 | // Reporter is used to report errors to honeybadger. 23 | type Reporter struct { 24 | Environment string 25 | 26 | // http client to use when sending reports to honeybadger. 27 | client interface { 28 | Send(*Report) error 29 | } 30 | 31 | cwd string 32 | hostname string 33 | } 34 | 35 | // NewReporter returns a new Reporter instance. 36 | func NewReporter(key string) *Reporter { 37 | cwd, _ := os.Getwd() 38 | hostname, _ := os.Hostname() 39 | 40 | return &Reporter{ 41 | client: NewClientFromKey(key), 42 | hostname: hostname, 43 | cwd: cwd, 44 | } 45 | } 46 | 47 | // Report reports the error to honeybadger. 48 | func (r *Reporter) Report(ctx context.Context, err error) error { 49 | report := r.NewReport(err) 50 | return r.client.Send(report) 51 | } 52 | 53 | func (r *Reporter) NewReport(err error) *Report { 54 | report := NewReport(err) 55 | report.Server.ProjectRoot["path"] = r.cwd 56 | report.Server.EnvironmentName = r.Environment 57 | report.Server.Hostname = r.hostname 58 | 59 | return report 60 | } 61 | 62 | // NewReport generates a new honeybadger report from an error. 63 | func NewReport(err error) *Report { 64 | r := &Report{ 65 | Notifier: &Notifier{ 66 | Name: "Honeybadger (Go)", 67 | Url: "https://github.com/remind101/pkg/reporter/hb", 68 | Version: "0.1", 69 | Language: "Go", 70 | }, 71 | Error: &Error{ 72 | Class: util.ClassName(err), 73 | Message: err.Error(), 74 | Backtrace: make([]*BacktraceLine, 0), 75 | Source: make(map[string]interface{}), 76 | }, 77 | Request: &Request{ 78 | Params: make(map[string]interface{}), 79 | Session: make(map[string]interface{}), 80 | CgiData: make(map[string]interface{}), 81 | Context: make(map[string]interface{}), 82 | }, 83 | Server: &Server{ 84 | ProjectRoot: make(map[string]interface{}), 85 | }, 86 | } 87 | 88 | if e, ok := err.(*reporter.Error); ok { 89 | r.Error.Class = util.ClassName(e.Err) 90 | 91 | for _, l := range e.Backtrace { 92 | r.Error.Backtrace = append(r.Error.Backtrace, &BacktraceLine{ 93 | Method: util.FunctionName(l.PC), 94 | File: l.File, 95 | Number: fmt.Sprintf("%d", l.Line), 96 | }) 97 | } 98 | 99 | if e.Request != nil { 100 | r.Request.Url = e.Request.URL.String() 101 | 102 | for header, values := range e.Request.Header { 103 | if _, ok := IgnoredHeaders[header]; ok { 104 | continue 105 | } 106 | 107 | h := strings.Replace(strings.ToUpper(header), "-", "_", -1) 108 | r.Request.CgiData["HTTP_"+h] = values 109 | } 110 | 111 | r.Request.CgiData["REQUEST_METHOD"] = e.Request.Method 112 | } 113 | 114 | for key, value := range e.Context { 115 | r.Request.Context[key] = value 116 | } 117 | } 118 | 119 | return r 120 | } 121 | -------------------------------------------------------------------------------- /Godeps/_workspace/src/github.com/fsouza/go-dockerclient/vendor/github.com/Sirupsen/logrus/json_formatter_test.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | 7 | "testing" 8 | ) 9 | 10 | func TestErrorNotLost(t *testing.T) { 11 | formatter := &JSONFormatter{} 12 | 13 | b, err := formatter.Format(WithField("error", errors.New("wild walrus"))) 14 | if err != nil { 15 | t.Fatal("Unable to format entry: ", err) 16 | } 17 | 18 | entry := make(map[string]interface{}) 19 | err = json.Unmarshal(b, &entry) 20 | if err != nil { 21 | t.Fatal("Unable to unmarshal formatted entry: ", err) 22 | } 23 | 24 | if entry["error"] != "wild walrus" { 25 | t.Fatal("Error field not set") 26 | } 27 | } 28 | 29 | func TestErrorNotLostOnFieldNotNamedError(t *testing.T) { 30 | formatter := &JSONFormatter{} 31 | 32 | b, err := formatter.Format(WithField("omg", errors.New("wild walrus"))) 33 | if err != nil { 34 | t.Fatal("Unable to format entry: ", err) 35 | } 36 | 37 | entry := make(map[string]interface{}) 38 | err = json.Unmarshal(b, &entry) 39 | if err != nil { 40 | t.Fatal("Unable to unmarshal formatted entry: ", err) 41 | } 42 | 43 | if entry["omg"] != "wild walrus" { 44 | t.Fatal("Error field not set") 45 | } 46 | } 47 | 48 | func TestFieldClashWithTime(t *testing.T) { 49 | formatter := &JSONFormatter{} 50 | 51 | b, err := formatter.Format(WithField("time", "right now!")) 52 | if err != nil { 53 | t.Fatal("Unable to format entry: ", err) 54 | } 55 | 56 | entry := make(map[string]interface{}) 57 | err = json.Unmarshal(b, &entry) 58 | if err != nil { 59 | t.Fatal("Unable to unmarshal formatted entry: ", err) 60 | } 61 | 62 | if entry["fields.time"] != "right now!" { 63 | t.Fatal("fields.time not set to original time field") 64 | } 65 | 66 | if entry["time"] != "0001-01-01T00:00:00Z" { 67 | t.Fatal("time field not set to current time, was: ", entry["time"]) 68 | } 69 | } 70 | 71 | func TestFieldClashWithMsg(t *testing.T) { 72 | formatter := &JSONFormatter{} 73 | 74 | b, err := formatter.Format(WithField("msg", "something")) 75 | if err != nil { 76 | t.Fatal("Unable to format entry: ", err) 77 | } 78 | 79 | entry := make(map[string]interface{}) 80 | err = json.Unmarshal(b, &entry) 81 | if err != nil { 82 | t.Fatal("Unable to unmarshal formatted entry: ", err) 83 | } 84 | 85 | if entry["fields.msg"] != "something" { 86 | t.Fatal("fields.msg not set to original msg field") 87 | } 88 | } 89 | 90 | func TestFieldClashWithLevel(t *testing.T) { 91 | formatter := &JSONFormatter{} 92 | 93 | b, err := formatter.Format(WithField("level", "something")) 94 | if err != nil { 95 | t.Fatal("Unable to format entry: ", err) 96 | } 97 | 98 | entry := make(map[string]interface{}) 99 | err = json.Unmarshal(b, &entry) 100 | if err != nil { 101 | t.Fatal("Unable to unmarshal formatted entry: ", err) 102 | } 103 | 104 | if entry["fields.level"] != "something" { 105 | t.Fatal("fields.level not set to original level field") 106 | } 107 | } 108 | 109 | func TestJSONEntryEndsWithNewline(t *testing.T) { 110 | formatter := &JSONFormatter{} 111 | 112 | b, err := formatter.Format(WithField("level", "something")) 113 | if err != nil { 114 | t.Fatal("Unable to format entry: ", err) 115 | } 116 | 117 | if b[len(b)-1] != '\n' { 118 | t.Fatal("Expected JSON log entry to end with a newline") 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /adapter.go: -------------------------------------------------------------------------------- 1 | package stats 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "math" 8 | "os" 9 | "text/template" 10 | 11 | "github.com/fsouza/go-dockerclient" 12 | ) 13 | 14 | var DefaultAdapter Adapter = &nullAdapter{} 15 | 16 | // L2MetTemplate is a template for outputing metrics as l2met samples. 17 | var L2MetTemplate = `{{.Type}}#{{.Name}}={{.Value}} source={{.Container.Name}}.{{.Hostname}}` 18 | 19 | type nullAdapter struct{} 20 | 21 | func (a *nullAdapter) Incr(c *docker.Container, n string, v uint64) {} 22 | func (a *nullAdapter) Sample(c *docker.Container, n string, v uint64) {} 23 | 24 | // LogAdapter is a drain that drains the metrics to stdout in l2met format. 25 | type LogAdapter struct { 26 | template *template.Template 27 | writer io.Writer 28 | } 29 | 30 | // NewLogAdapter parses the template string as a text/template and returns a new 31 | // LogAdapter instance. 32 | func NewLogAdapter(tmpl string, w io.Writer) (*LogAdapter, error) { 33 | if tmpl == "" { 34 | tmpl = L2MetTemplate 35 | } 36 | 37 | if w == nil { 38 | w = os.Stdout 39 | } 40 | 41 | t, err := template.New("stat").Parse(tmpl) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | return &LogAdapter{ 47 | template: t, 48 | writer: w, 49 | }, nil 50 | } 51 | 52 | func (a *LogAdapter) Sample(c *docker.Container, name string, value uint64) { 53 | a.write(c, "sample", name, value) 54 | } 55 | 56 | func (a *LogAdapter) Incr(c *docker.Container, name string, value uint64) { 57 | a.write(c, "count", name, value) 58 | } 59 | 60 | func (a *LogAdapter) write(c *docker.Container, typ, name string, value uint64) { 61 | data := stat{ 62 | Container: c, 63 | Type: typ, 64 | Name: name, 65 | Value: value, 66 | } 67 | fmt.Fprintln(a.writer, renderTemplate(a.template, data)) 68 | } 69 | 70 | // StatsdTemplate defines the template used to render the statsd metric name. 71 | var StatsdTemplate = `{{.Name}}.source__{{.Container.Name}}.{{.Hostname}}__` 72 | 73 | type StatsdClient interface { 74 | Incr(name string, value int64) error 75 | Gauge(name string, value int64) error 76 | } 77 | 78 | type StatsdAdapter struct { 79 | client StatsdClient 80 | template *template.Template 81 | } 82 | 83 | func NewStatsdAdapter(c StatsdClient, tmpl string) (*StatsdAdapter, error) { 84 | if tmpl == "" { 85 | tmpl = StatsdTemplate 86 | } 87 | 88 | t, err := template.New("stat").Parse(tmpl) 89 | if err != nil { 90 | return nil, err 91 | } 92 | 93 | return &StatsdAdapter{ 94 | client: c, 95 | template: t, 96 | }, nil 97 | 98 | } 99 | 100 | func (a *StatsdAdapter) Incr(c *docker.Container, name string, value uint64) { 101 | if value <= math.MaxInt64 { 102 | a.client.Incr(a.name(c, name), int64(value)) 103 | } 104 | } 105 | 106 | func (a *StatsdAdapter) Sample(c *docker.Container, name string, value uint64) { 107 | if value <= math.MaxInt64 { 108 | a.client.Gauge(a.name(c, name), int64(value)) 109 | } 110 | } 111 | 112 | func (a *StatsdAdapter) name(c *docker.Container, name string) string { 113 | data := stat{ 114 | Container: c, 115 | Name: name, 116 | } 117 | return renderTemplate(a.template, data) 118 | } 119 | 120 | func renderTemplate(t *template.Template, data stat) string { 121 | b := new(bytes.Buffer) 122 | if err := t.Execute(b, data); err != nil { 123 | panic(err) 124 | } 125 | return b.String() 126 | } 127 | --------------------------------------------------------------------------------