Skip to content

Commit

Permalink
Update external dependencies
Browse files Browse the repository at this point in the history
In particular this updates logrus and docker to versions which can be
build on Solaris.
  • Loading branch information
jen20 committed Jan 2, 2016
1 parent e0d22d3 commit 34b7825
Show file tree
Hide file tree
Showing 232 changed files with 100,199 additions and 1,149 deletions.
11 changes: 9 additions & 2 deletions external/github.com/Sirupsen/logrus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
| [InfluxDB](https://github.com/Abramovic/logrus_influxdb) | Hook for logging to influxdb |
| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
| [DeferPanic](https://github.com/deferpanic/dp-logrus) | Hook for logging to DeferPanic |

#### Level logging

Expand Down Expand Up @@ -300,12 +301,13 @@ The built-in logging formatters are:
* `logrus/formatters/logstash.LogstashFormatter`. Logs fields as [Logstash](http://logstash.net) Events.

```go
logrus.SetFormatter(&logstash.LogstashFormatter{Type: application_name"})
logrus.SetFormatter(&logstash.LogstashFormatter{Type: "application_name"})
```

Third party logging formatters:

* [`zalgo`](https://github.com/aybabtme/logzalgo): invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦.
* [`prefixed`](https://github.com/x-cray/logrus-prefixed-formatter). Displays log entry source along with alternative layout.
* [`zalgo`](https://github.com/aybabtme/logzalgo). Invoking the P͉̫o̳̼̊w̖͈̰͎e̬͔̭͂r͚̼̹̲ ̫͓͉̳͈ō̠͕͖̚f̝͍̠ ͕̲̞͖͑Z̖̫̤̫ͪa͉̬͈̗l͖͎g̳̥o̰̥̅!̣͔̲̻͊̄ ̙̘̦̹̦.

You can define your formatter by implementing the `Formatter` interface,
requiring a `Format` method. `Format` takes an `*Entry`. `entry.Data` is a
Expand Down Expand Up @@ -354,5 +356,10 @@ Log rotation is not provided with Logrus. Log rotation should be done by an
external program (like `logrotate(8)`) that can compress and delete old log
entries. It should not be a feature of the application-level logger.

#### Tools

| Tool | Description |
| ---- | ----------- |
|[Logrus Mate](https://github.com/gogap/logrus_mate)|Logrus mate is a tool for Logrus to manage loggers, you can initial logger's level, hook and formatter by config file, the logger will generated with different config at different environment.|

[godoc]: https://godoc.org/github.com/Sirupsen/logrus
16 changes: 13 additions & 3 deletions external/github.com/Sirupsen/logrus/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"time"
)

// Defines the key when adding errors using WithError.
var ErrorKey = "error"

// An entry is the final or intermediate Logrus logging entry. It contains all
// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
Expand Down Expand Up @@ -53,6 +56,11 @@ func (entry *Entry) String() (string, error) {
return reader.String(), err
}

// Add an error as single field (using the key defined in ErrorKey) to the Entry.
func (entry *Entry) WithError(err error) *Entry {
return entry.WithField(ErrorKey, err)
}

// Add a single field to the Entry.
func (entry *Entry) WithField(key string, value interface{}) *Entry {
return entry.WithFields(Fields{key: value})
Expand All @@ -70,12 +78,14 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
return &Entry{Logger: entry.Logger, Data: data}
}

func (entry *Entry) log(level Level, msg string) {
// This function is not declared with a pointer value because otherwise
// race conditions will occur when using multiple goroutines
func (entry Entry) log(level Level, msg string) {
entry.Time = time.Now()
entry.Level = level
entry.Message = msg

if err := entry.Logger.Hooks.Fire(level, entry); err != nil {
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
entry.Logger.mu.Lock()
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
entry.Logger.mu.Unlock()
Expand All @@ -100,7 +110,7 @@ func (entry *Entry) log(level Level, msg string) {
// panic() to use in Entry#Panic(), we avoid the allocation by checking
// directly here.
if level <= PanicLevel {
panic(entry)
panic(&entry)
}
}

Expand Down
24 changes: 24 additions & 0 deletions external/github.com/Sirupsen/logrus/entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,30 @@ import (
"github.com/fsouza/go-dockerclient/external/github.com/stretchr/testify/assert"
)

func TestEntryWithError(t *testing.T) {

assert := assert.New(t)

defer func() {
ErrorKey = "error"
}()

err := fmt.Errorf("kaboom at layer %d", 4711)

assert.Equal(err, WithError(err).Data["error"])

logger := New()
logger.Out = &bytes.Buffer{}
entry := NewEntry(logger)

assert.Equal(err, entry.WithError(err).Data["error"])

ErrorKey = "err"

assert.Equal(err, entry.WithError(err).Data["err"])

}

func TestEntryPanicln(t *testing.T) {
errBoom := fmt.Errorf("boom time")

Expand Down
5 changes: 5 additions & 0 deletions external/github.com/Sirupsen/logrus/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func AddHook(hook Hook) {
std.Hooks.Add(hook)
}

// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
func WithError(err error) *Entry {
return std.WithField(ErrorKey, err)
}

// WithField creates an entry from the standard logger and adds a field to
// it. If you want multiple fields, use `WithFields`.
//
Expand Down
10 changes: 8 additions & 2 deletions external/github.com/Sirupsen/logrus/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type Logger struct {
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
// file, or leave it default which is `os.Stdout`. You can also set this to
// file, or leave it default which is `os.Stderr`. You can also set this to
// something more adventorous, such as logging to Kafka.
Out io.Writer
// Hooks for the logger instance. These allow firing events based on logging
Expand Down Expand Up @@ -53,7 +53,7 @@ func New() *Logger {

// Adds a field to the log entry, note that you it doesn't log until you call
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
// Ff you want multiple fields, use `WithFields`.
// If you want multiple fields, use `WithFields`.
func (logger *Logger) WithField(key string, value interface{}) *Entry {
return NewEntry(logger).WithField(key, value)
}
Expand All @@ -64,6 +64,12 @@ func (logger *Logger) WithFields(fields Fields) *Entry {
return NewEntry(logger).WithFields(fields)
}

// Add an error as single field to the log entry. All it does is call
// `WithError` for the given `error`.
func (logger *Logger) WithError(err error) *Entry {
return NewEntry(logger).WithError(err)
}

func (logger *Logger) Debugf(format string, args ...interface{}) {
if logger.Level >= DebugLevel {
NewEntry(logger).Debugf(format, args...)
Expand Down
6 changes: 5 additions & 1 deletion external/github.com/Sirupsen/logrus/logrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ const (
)

// Won't compile if StdLogger can't be realized by a log.Logger
var _ StdLogger = &log.Logger{}
var (
_ StdLogger = &log.Logger{}
_ StdLogger = &Entry{}
_ StdLogger = &Logger{}
)

// StdLogger is what your logrus-enabled library should take, that way
// it'll accept a stdlib logger and a logrus logger. There's no standard
Expand Down
4 changes: 2 additions & 2 deletions external/github.com/Sirupsen/logrus/terminal_notwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"unsafe"
)

// IsTerminal returns true if the given file descriptor is a terminal.
// IsTerminal returns true if stderr's file descriptor is a terminal.
func IsTerminal() bool {
fd := syscall.Stdout
fd := syscall.Stderr
var termios Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
Expand Down
15 changes: 15 additions & 0 deletions external/github.com/Sirupsen/logrus/terminal_solaris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// +build solaris

package logrus

import (
"os"

"github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix"
)

// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool {
_, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
return err == nil
}
4 changes: 2 additions & 2 deletions external/github.com/Sirupsen/logrus/terminal_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var (
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
)

// IsTerminal returns true if the given file descriptor is a terminal.
// IsTerminal returns true if stderr's file descriptor is a terminal.
func IsTerminal() bool {
fd := syscall.Stdout
fd := syscall.Stderr
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
Expand Down
85 changes: 51 additions & 34 deletions external/github.com/docker/docker/errors/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var (
// name or ID and we can't find it.
ErrorCodeNoSuchContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "NOSUCHCONTAINER",
Message: "no such id: %s",
Message: "No such container: %s",
Description: "The specified container can not be found",
HTTPStatusCode: http.StatusNotFound,
})
Expand Down Expand Up @@ -46,6 +46,14 @@ var (
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodePausedContainer is generated when we attempt to attach a
// container but its paused.
ErrorCodePausedContainer = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CONTAINERPAUSED",
Message: "Container %s is paused. Unpause the container before attach",
Description: "The specified container is paused, unpause the container before attach",
HTTPStatusCode: http.StatusConflict,
})
// ErrorCodeAlreadyPaused is generated when we attempt to pause a
// container when its already paused.
ErrorCodeAlreadyPaused = errcode.Register(errGroup, errcode.ErrorDescriptor{
Expand Down Expand Up @@ -73,7 +81,7 @@ var (
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeEmptyID is generated when an ID is the emptry string.
// ErrorCodeEmptyID is generated when an ID is the empty string.
ErrorCodeEmptyID = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "EMPTYID",
Message: "Invalid empty id",
Expand Down Expand Up @@ -359,11 +367,11 @@ var (
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeVolumeInvalidMode is generated when we the mode of a volume/bind
// ErrorCodeVolumeInvalidMode is generated when the mode of a volume/bind
// mount is invalid.
ErrorCodeVolumeInvalidMode = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEINVALIDMODE",
Message: "invalid mode: %s",
Message: "invalid mode: %q",
Description: "An invalid 'mode' was specified",
HTTPStatusCode: http.StatusInternalServerError,
})
Expand All @@ -372,23 +380,23 @@ var (
// volume specification isn't valid.
ErrorCodeVolumeInvalid = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEINVALID",
Message: "Invalid volume specification: %s",
Message: "Invalid volume specification: '%s'",
Description: "An invalid 'volume' was specified in the mount request",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeVolumeAbs is generated when path to a volume isn't absolute.
ErrorCodeVolumeAbs = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEABS",
Message: "Invalid volume destination path: %s mount path must be absolute.",
Message: "Invalid volume destination path: '%s' mount path must be absolute.",
Description: "An invalid 'destination' path was specified in the mount request, it must be an absolute path",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeVolumeName is generated when the name of named volume isn't valid.
ErrorCodeVolumeName = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUME_NAME_INVALID",
Message: "%s includes invalid characters for a local volume name, only %s are allowed",
Message: "%q includes invalid characters for a local volume name, only %q are allowed",
Description: "The name of volume is invalid",
HTTPStatusCode: http.StatusBadRequest,
})
Expand Down Expand Up @@ -417,7 +425,7 @@ var (
// ErrorCodeVolumeSourceNotFound is generated the source directory could not be found (Windows specific)
ErrorCodeVolumeSourceNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMESOURCENOTFOUND",
Message: "Source directory '%s' could not be found: %v",
Message: "Source directory '%s' could not be found: %s",
HTTPStatusCode: http.StatusInternalServerError,
})

Expand All @@ -431,25 +439,25 @@ var (
// ErrorCodeVolumeFromBlank is generated when path to a volume is blank.
ErrorCodeVolumeFromBlank = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEFROMBLANK",
Message: "malformed volumes-from specification: %s",
Message: "malformed volumes-from specification: %q",
Description: "An invalid 'destination' path was specified in the mount request, it must not be blank",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeVolumeDup is generated when we try to mount two volumes
// ErrorCodeMountDup is generated when we try to mount two mounts points
// to the same path.
ErrorCodeVolumeDup = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMEDUP",
Message: "Duplicate bind mount %s",
Description: "An attempt was made to mount a volume but the specified destination location is already used in a previous mount",
ErrorCodeMountDup = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "MOUNTDUP",
Message: "Duplicate mount point '%s'",
Description: "An attempt was made to mount a content but the specified destination location is already used in a previous mount",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeVolumeNoSourceForMount is generated when no source directory
// for a volume mount was found. (Windows specific)
ErrorCodeVolumeNoSourceForMount = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUMENOSOURCEFORMOUNT",
Message: "No source for mount name %q driver %q destination %s",
Message: "No source for mount name '%s' driver %q destination '%s'",
HTTPStatusCode: http.StatusInternalServerError,
})

Expand Down Expand Up @@ -591,15 +599,6 @@ var (
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeCantStart is generated when an error occurred while
// trying to start a container.
ErrorCodeCantStart = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CANTSTART",
Message: "Cannot start container %s: %s",
Description: "There was an error while trying to start a container",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeCantRestart is generated when an error occurred while
// trying to restart a container.
ErrorCodeCantRestart = errcode.Register(errGroup, errcode.ErrorDescriptor{
Expand Down Expand Up @@ -833,15 +832,6 @@ var (
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeRmInit is generated when we try to delete a container
// but failed deleting its init filesystem.
ErrorCodeRmInit = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "RMINIT",
Message: "Driver %s failed to remove init filesystem %s: %s",
Description: "While trying to delete a container, the driver failed to remove the init filesystem",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeRmFS is generated when we try to delete a container
// but failed deleting its filesystem.
ErrorCodeRmFS = errcode.Register(errGroup, errcode.ErrorDescriptor{
Expand Down Expand Up @@ -918,8 +908,35 @@ var (
// trying to create a volume that has existed using different driver.
ErrorVolumeNameTaken = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "VOLUME_NAME_TAKEN",
Message: "A volume name %s already exists with the %s driver. Choose a different volume name.",
Message: "A volume named %q already exists with the %q driver. Choose a different volume name.",
Description: "An attempt to create a volume using a driver but the volume already exists with a different driver",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeCmdNotFound is generated when container cmd can't start,
// container command not found error, exit code 127
ErrorCodeCmdNotFound = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CMDNOTFOUND",
Message: "Container command not found or does not exist.",
Description: "Command could not be found, command does not exist",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeCmdCouldNotBeInvoked is generated when container cmd can't start,
// container command permission denied error, exit code 126
ErrorCodeCmdCouldNotBeInvoked = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CMDCOULDNOTBEINVOKED",
Message: "Container command could not be invoked.",
Description: "Permission denied, cannot invoke command",
HTTPStatusCode: http.StatusInternalServerError,
})

// ErrorCodeCantStart is generated when container cmd can't start,
// for any reason other than above 2 errors
ErrorCodeCantStart = errcode.Register(errGroup, errcode.ErrorDescriptor{
Value: "CANTSTART",
Message: "Cannot start container %s: %s",
Description: "There was an error while trying to start a container",
HTTPStatusCode: http.StatusInternalServerError,
})
)
Loading

0 comments on commit 34b7825

Please sign in to comment.