diff --git a/libnetwork/Godeps/Godeps.json b/libnetwork/Godeps/Godeps.json index 10bca97a7c..b1f35ffc04 100644 --- a/libnetwork/Godeps/Godeps.json +++ b/libnetwork/Godeps/Godeps.json @@ -7,11 +7,11 @@ "Deps": [ { "ImportPath": "github.com/Azure/go-ansiterm", - "Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe" + "Rev": "04b7f292a41fcb5da32dda536c0807fc13e8351c" }, { "ImportPath": "github.com/Azure/go-ansiterm/winterm", - "Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe" + "Rev": "04b7f292a41fcb5da32dda536c0807fc13e8351c" }, { "ImportPath": "github.com/BurntSushi/toml", @@ -47,7 +47,7 @@ }, { "ImportPath": "github.com/codegangsta/cli", - "Comment": "1.2.0-143-ga65b733", + "Comment": "v1.9.0", "Rev": "a65b733b303f0055f8d324d805f393cd3e7a7904" }, { @@ -82,119 +82,109 @@ }, { "ImportPath": "github.com/docker/docker/opts", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/discovery", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/discovery/kv", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/homedir", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/ioutils", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/longpath", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/mflag", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/mount", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/parsers/kernel", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/plugins", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/plugins/transport", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/random", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/reexec", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/signal", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/stringid", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/symlink", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/system", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/term", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/term/windows", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/docker/pkg/tlsconfig", - "Comment": "v1.4.1-11716-g24076ed", - "Rev": "24076ed4d9c82d387029b8a65e21873db5676f6a" - }, - { - "ImportPath": "github.com/docker/engine-api/types/filters", - "Comment": "v0.3.1-210-g25941ec", - "Rev": "25941ecf6e8351810e8530c60de8dda7d5e1baba" + "Comment": "v1.4.1-12227-g86a7632", + "Rev": "86a7632d63bdddb95aaf1472648056a4fb737d38" }, { "ImportPath": "github.com/docker/engine-api/types/network", "Comment": "v0.3.1-210-g25941ec", "Rev": "25941ecf6e8351810e8530c60de8dda7d5e1baba" }, - { - "ImportPath": "github.com/docker/engine-api/types/versions", - "Comment": "v0.3.1-210-g25941ec", - "Rev": "25941ecf6e8351810e8530c60de8dda7d5e1baba" - }, { "ImportPath": "github.com/docker/go-connections/sockets", "Comment": "v0.2.0", @@ -303,11 +293,6 @@ "Comment": "v0.7.0-47-g598c548", "Rev": "598c54895cc5a7b1a24a398d635e8c0ea0959870" }, - { - "ImportPath": "github.com/mattn/go-shellwords", - "Comment": "v1.0.0-1-g525bede", - "Rev": "525bedee691b5a8df547cb5cf9f86b7fb1883e24" - }, { "ImportPath": "github.com/miekg/dns", "Rev": "d27455715200c7d3e321a1e5cadb27c9ee0b0f02" diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/constants.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/constants.go index ebfce8a8d3..96504a33bc 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/constants.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/constants.go @@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte { return bytes } -var ToGroundBytes = getToGroundBytes() -var Executors = getExecuteBytes() +var toGroundBytes = getToGroundBytes() +var executors = getExecuteBytes() // SPACE 20+A0 hex Always and everywhere a blank space // Intermediate 20-2F hex !"#$%&'()*+,-./ -var Intermeds = getByteRange(0x20, 0x2F) +var intermeds = getByteRange(0x20, 0x2F) // Parameters 30-3F hex 0123456789:;<=>? // CSI Parameters 30-39, 3B hex 0123456789; -var CsiParams = getByteRange(0x30, 0x3F) +var csiParams = getByteRange(0x30, 0x3F) -var CsiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...) +var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...) // Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ -var UpperCase = getByteRange(0x40, 0x5F) +var upperCase = getByteRange(0x40, 0x5F) // Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~ -var LowerCase = getByteRange(0x60, 0x7E) +var lowerCase = getByteRange(0x60, 0x7E) // Alphabetics 40-7E hex (all of upper and lower case) -var Alphabetics = append(UpperCase, LowerCase...) +var alphabetics = append(upperCase, lowerCase...) -var Printables = getByteRange(0x20, 0x7F) +var printables = getByteRange(0x20, 0x7F) -var EscapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E) -var EscapeToGroundBytes = getEscapeToGroundBytes() +var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E) +var escapeToGroundBytes = getEscapeToGroundBytes() // See http://www.vt100.net/emu/vt500_parser.png for description of the complex // byte ranges below diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/context.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/context.go index d55cc2aec7..8d66e777c0 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/context.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/context.go @@ -1,6 +1,6 @@ package ansiterm -type AnsiContext struct { +type ansiContext struct { currentChar byte paramBuffer []byte interBuffer []byte diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_entry_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_entry_state.go index 9fd4bd28e2..1bd6057da8 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_entry_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_entry_state.go @@ -1,41 +1,41 @@ package ansiterm -type CsiEntryState struct { - BaseState +type csiEntryState struct { + baseState } -func (csiState CsiEntryState) Handle(b byte) (s State, e error) { +func (csiState csiEntryState) Handle(b byte) (s state, e error) { logger.Infof("CsiEntry::Handle %#x", b) - nextState, err := csiState.BaseState.Handle(b) + nextState, err := csiState.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { - case sliceContains(Alphabetics, b): - return csiState.parser.Ground, nil - case sliceContains(CsiCollectables, b): - return csiState.parser.CsiParam, nil - case sliceContains(Executors, b): + case sliceContains(alphabetics, b): + return csiState.parser.ground, nil + case sliceContains(csiCollectables, b): + return csiState.parser.csiParam, nil + case sliceContains(executors, b): return csiState, csiState.parser.execute() } return csiState, nil } -func (csiState CsiEntryState) Transition(s State) error { +func (csiState csiEntryState) Transition(s state) error { logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name()) - csiState.BaseState.Transition(s) + csiState.baseState.Transition(s) switch s { - case csiState.parser.Ground: + case csiState.parser.ground: return csiState.parser.csiDispatch() - case csiState.parser.CsiParam: + case csiState.parser.csiParam: switch { - case sliceContains(CsiParams, csiState.parser.context.currentChar): + case sliceContains(csiParams, csiState.parser.context.currentChar): csiState.parser.collectParam() - case sliceContains(Intermeds, csiState.parser.context.currentChar): + case sliceContains(intermeds, csiState.parser.context.currentChar): csiState.parser.collectInter() } } @@ -43,7 +43,7 @@ func (csiState CsiEntryState) Transition(s State) error { return nil } -func (csiState CsiEntryState) Enter() error { +func (csiState csiEntryState) Enter() error { csiState.parser.clear() return nil } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_param_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_param_state.go index 27807dd35b..4be35c5fd2 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_param_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/csi_param_state.go @@ -1,36 +1,36 @@ package ansiterm -type CsiParamState struct { - BaseState +type csiParamState struct { + baseState } -func (csiState CsiParamState) Handle(b byte) (s State, e error) { +func (csiState csiParamState) Handle(b byte) (s state, e error) { logger.Infof("CsiParam::Handle %#x", b) - nextState, err := csiState.BaseState.Handle(b) + nextState, err := csiState.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { - case sliceContains(Alphabetics, b): - return csiState.parser.Ground, nil - case sliceContains(CsiCollectables, b): + case sliceContains(alphabetics, b): + return csiState.parser.ground, nil + case sliceContains(csiCollectables, b): csiState.parser.collectParam() return csiState, nil - case sliceContains(Executors, b): + case sliceContains(executors, b): return csiState, csiState.parser.execute() } return csiState, nil } -func (csiState CsiParamState) Transition(s State) error { +func (csiState csiParamState) Transition(s state) error { logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name()) - csiState.BaseState.Transition(s) + csiState.baseState.Transition(s) switch s { - case csiState.parser.Ground: + case csiState.parser.ground: return csiState.parser.csiDispatch() } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_intermediate_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_intermediate_state.go index b14e0ce977..2189eb6b6b 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_intermediate_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_intermediate_state.go @@ -1,34 +1,34 @@ package ansiterm -type EscapeIntermediateState struct { - BaseState +type escapeIntermediateState struct { + baseState } -func (escState EscapeIntermediateState) Handle(b byte) (s State, e error) { - logger.Infof("EscapeIntermediateState::Handle %#x", b) - nextState, err := escState.BaseState.Handle(b) +func (escState escapeIntermediateState) Handle(b byte) (s state, e error) { + logger.Infof("escapeIntermediateState::Handle %#x", b) + nextState, err := escState.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { - case sliceContains(Intermeds, b): + case sliceContains(intermeds, b): return escState, escState.parser.collectInter() - case sliceContains(Executors, b): + case sliceContains(executors, b): return escState, escState.parser.execute() - case sliceContains(EscapeIntermediateToGroundBytes, b): - return escState.parser.Ground, nil + case sliceContains(escapeIntermediateToGroundBytes, b): + return escState.parser.ground, nil } return escState, nil } -func (escState EscapeIntermediateState) Transition(s State) error { - logger.Infof("EscapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name()) - escState.BaseState.Transition(s) +func (escState escapeIntermediateState) Transition(s state) error { + logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name()) + escState.baseState.Transition(s) switch s { - case escState.parser.Ground: + case escState.parser.ground: return escState.parser.escDispatch() } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_state.go index 232dd8e0d1..7b1b9ad3f1 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/escape_state.go @@ -1,47 +1,47 @@ package ansiterm -type EscapeState struct { - BaseState +type escapeState struct { + baseState } -func (escState EscapeState) Handle(b byte) (s State, e error) { - logger.Infof("EscapeState::Handle %#x", b) - nextState, err := escState.BaseState.Handle(b) +func (escState escapeState) Handle(b byte) (s state, e error) { + logger.Infof("escapeState::Handle %#x", b) + nextState, err := escState.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { case b == ANSI_ESCAPE_SECONDARY: - return escState.parser.CsiEntry, nil + return escState.parser.csiEntry, nil case b == ANSI_OSC_STRING_ENTRY: - return escState.parser.OscString, nil - case sliceContains(Executors, b): + return escState.parser.oscString, nil + case sliceContains(executors, b): return escState, escState.parser.execute() - case sliceContains(EscapeToGroundBytes, b): - return escState.parser.Ground, nil - case sliceContains(Intermeds, b): - return escState.parser.EscapeIntermediate, nil + case sliceContains(escapeToGroundBytes, b): + return escState.parser.ground, nil + case sliceContains(intermeds, b): + return escState.parser.escapeIntermediate, nil } return escState, nil } -func (escState EscapeState) Transition(s State) error { +func (escState escapeState) Transition(s state) error { logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name()) - escState.BaseState.Transition(s) + escState.baseState.Transition(s) switch s { - case escState.parser.Ground: + case escState.parser.ground: return escState.parser.escDispatch() - case escState.parser.EscapeIntermediate: + case escState.parser.escapeIntermediate: return escState.parser.collectInter() } return nil } -func (escState EscapeState) Enter() error { +func (escState escapeState) Enter() error { escState.parser.clear() return nil } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/ground_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/ground_state.go index d600e3e4ae..52451e9469 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/ground_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/ground_state.go @@ -1,22 +1,22 @@ package ansiterm -type GroundState struct { - BaseState +type groundState struct { + baseState } -func (gs GroundState) Handle(b byte) (s State, e error) { +func (gs groundState) Handle(b byte) (s state, e error) { gs.parser.context.currentChar = b - nextState, err := gs.BaseState.Handle(b) + nextState, err := gs.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { - case sliceContains(Printables, b): + case sliceContains(printables, b): return gs, gs.parser.print() - case sliceContains(Executors, b): + case sliceContains(executors, b): return gs, gs.parser.execute() } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/osc_string_state.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/osc_string_state.go index 4490e3cdf6..24062d420e 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/osc_string_state.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/osc_string_state.go @@ -1,19 +1,19 @@ package ansiterm -type OscStringState struct { - BaseState +type oscStringState struct { + baseState } -func (oscState OscStringState) Handle(b byte) (s State, e error) { +func (oscState oscStringState) Handle(b byte) (s state, e error) { logger.Infof("OscString::Handle %#x", b) - nextState, err := oscState.BaseState.Handle(b) + nextState, err := oscState.baseState.Handle(b) if nextState != nil || err != nil { return nextState, err } switch { case isOscStringTerminator(b): - return oscState.parser.Ground, nil + return oscState.parser.ground, nil } return oscState, nil diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser.go index ef5e0ad199..169f68dbef 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser.go @@ -2,7 +2,6 @@ package ansiterm import ( "errors" - "fmt" "io/ioutil" "os" @@ -12,18 +11,18 @@ import ( var logger *logrus.Logger type AnsiParser struct { - currState State + currState state eventHandler AnsiEventHandler - context *AnsiContext - CsiEntry State - CsiParam State - DcsEntry State - Escape State - EscapeIntermediate State - Error State - Ground State - OscString State - stateMap []State + context *ansiContext + csiEntry state + csiParam state + dcsEntry state + escape state + escapeIntermediate state + error state + ground state + oscString state + stateMap []state } func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser { @@ -41,27 +40,27 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser parser := &AnsiParser{ eventHandler: evtHandler, - context: &AnsiContext{}, + context: &ansiContext{}, } - parser.CsiEntry = CsiEntryState{BaseState{name: "CsiEntry", parser: parser}} - parser.CsiParam = CsiParamState{BaseState{name: "CsiParam", parser: parser}} - parser.DcsEntry = DcsEntryState{BaseState{name: "DcsEntry", parser: parser}} - parser.Escape = EscapeState{BaseState{name: "Escape", parser: parser}} - parser.EscapeIntermediate = EscapeIntermediateState{BaseState{name: "EscapeIntermediate", parser: parser}} - parser.Error = ErrorState{BaseState{name: "Error", parser: parser}} - parser.Ground = GroundState{BaseState{name: "Ground", parser: parser}} - parser.OscString = OscStringState{BaseState{name: "OscString", parser: parser}} + parser.csiEntry = csiEntryState{baseState{name: "CsiEntry", parser: parser}} + parser.csiParam = csiParamState{baseState{name: "CsiParam", parser: parser}} + parser.dcsEntry = dcsEntryState{baseState{name: "DcsEntry", parser: parser}} + parser.escape = escapeState{baseState{name: "Escape", parser: parser}} + parser.escapeIntermediate = escapeIntermediateState{baseState{name: "EscapeIntermediate", parser: parser}} + parser.error = errorState{baseState{name: "Error", parser: parser}} + parser.ground = groundState{baseState{name: "Ground", parser: parser}} + parser.oscString = oscStringState{baseState{name: "OscString", parser: parser}} - parser.stateMap = []State{ - parser.CsiEntry, - parser.CsiParam, - parser.DcsEntry, - parser.Escape, - parser.EscapeIntermediate, - parser.Error, - parser.Ground, - parser.OscString, + parser.stateMap = []state{ + parser.csiEntry, + parser.csiParam, + parser.dcsEntry, + parser.escape, + parser.escapeIntermediate, + parser.error, + parser.ground, + parser.oscString, } parser.currState = getState(initialState, parser.stateMap) @@ -70,7 +69,7 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser return parser } -func getState(name string, states []State) State { +func getState(name string, states []state) state { for _, el := range states { if el.Name() == name { return el @@ -99,7 +98,7 @@ func (ap *AnsiParser) handle(b byte) error { if newState == nil { logger.Warning("newState is nil") - return errors.New(fmt.Sprintf("New state of 'nil' is invalid.")) + return errors.New("New state of 'nil' is invalid.") } if newState != ap.currState { @@ -111,7 +110,7 @@ func (ap *AnsiParser) handle(b byte) error { return nil } -func (ap *AnsiParser) changeState(newState State) error { +func (ap *AnsiParser) changeState(newState state) error { logger.Infof("ChangeState %s --> %s", ap.currState.Name(), newState.Name()) // Exit old state diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_action_helpers.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_action_helpers.go index 438802097d..8b69a67a5a 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_action_helpers.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_action_helpers.go @@ -31,7 +31,7 @@ func parseParams(bytes []byte) ([]string, error) { return params, nil } -func parseCmd(context AnsiContext) (string, error) { +func parseCmd(context ansiContext) (string, error) { return string(context.currentChar), nil } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_actions.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_actions.go index 260e6aae3c..58750a2d2b 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_actions.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_actions.go @@ -113,7 +113,7 @@ func (ap *AnsiParser) print() error { } func (ap *AnsiParser) clear() error { - ap.context = &AnsiContext{} + ap.context = &ansiContext{} return nil } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_helpers.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_helpers.go deleted file mode 100644 index 562f215d34..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_helpers.go +++ /dev/null @@ -1,114 +0,0 @@ -package ansiterm - -import ( - "fmt" - "testing" -) - -func getStateNames() []string { - parser, _ := createTestParser("Ground") - - stateNames := []string{} - for _, state := range parser.stateMap { - stateNames = append(stateNames, state.Name()) - } - - return stateNames -} - -func stateTransitionHelper(t *testing.T, start string, end string, bytes []byte) { - for _, b := range bytes { - bytes := []byte{byte(b)} - parser, _ := createTestParser(start) - parser.Parse(bytes) - validateState(t, parser.currState, end) - } -} - -func anyToXHelper(t *testing.T, bytes []byte, expectedState string) { - for _, s := range getStateNames() { - stateTransitionHelper(t, s, expectedState, bytes) - } -} - -func funcCallParamHelper(t *testing.T, bytes []byte, start string, expected string, expectedCalls []string) { - parser, evtHandler := createTestParser(start) - parser.Parse(bytes) - validateState(t, parser.currState, expected) - validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls) -} - -func parseParamsHelper(t *testing.T, bytes []byte, expectedParams []string) { - params, err := parseParams(bytes) - - if err != nil { - t.Errorf("Parameter parse error: %v", err) - return - } - - if len(params) != len(expectedParams) { - t.Errorf("Parsed parameters: %v", params) - t.Errorf("Expected parameters: %v", expectedParams) - t.Errorf("Parameter length failure: %d != %d", len(params), len(expectedParams)) - return - } - - for i, v := range expectedParams { - if v != params[i] { - t.Errorf("Parsed parameters: %v", params) - t.Errorf("Expected parameters: %v", expectedParams) - t.Errorf("Parameter parse failure: %s != %s at position %d", v, params[i], i) - } - } -} - -func cursorSingleParamHelper(t *testing.T, command byte, funcName string) { - funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)}) - funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23])", funcName)}) - funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)}) - funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)}) -} - -func cursorTwoParamHelper(t *testing.T, command byte, funcName string) { - funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)}) - funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)}) - funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 1])", funcName)}) - funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23 1])", funcName)}) - funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)}) - funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)}) -} - -func eraseHelper(t *testing.T, command byte, funcName string) { - funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)}) - funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)}) - funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)}) - funcCallParamHelper(t, []byte{'3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([3])", funcName)}) - funcCallParamHelper(t, []byte{'4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)}) - funcCallParamHelper(t, []byte{'1', ';', '2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) -} - -func scrollHelper(t *testing.T, command byte, funcName string) { - funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)}) - funcCallParamHelper(t, []byte{'5', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([5])", funcName)}) - funcCallParamHelper(t, []byte{'4', ';', '6', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([4])", funcName)}) -} - -func clearOnStateChangeHelper(t *testing.T, start string, end string, bytes []byte) { - p, _ := createTestParser(start) - fillContext(p.context) - p.Parse(bytes) - validateState(t, p.currState, end) - validateEmptyContext(t, p.context) -} - -func c0Helper(t *testing.T, bytes []byte, expectedState string, expectedCalls []string) { - parser, evtHandler := createTestParser("Ground") - parser.Parse(bytes) - validateState(t, parser.currState, expectedState) - validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls) -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_utilities.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_utilities.go deleted file mode 100644 index 51d1d49bf0..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/parser_test_utilities.go +++ /dev/null @@ -1,66 +0,0 @@ -package ansiterm - -import ( - "testing" -) - -func createTestParser(s string) (*AnsiParser, *TestAnsiEventHandler) { - evtHandler := CreateTestAnsiEventHandler() - parser := CreateParser(s, evtHandler) - - return parser, evtHandler -} - -func validateState(t *testing.T, actualState State, expectedStateName string) { - actualName := "Nil" - - if actualState != nil { - actualName = actualState.Name() - } - - if actualName != expectedStateName { - t.Errorf("Invalid State: '%s' != '%s'", actualName, expectedStateName) - } -} - -func validateFuncCalls(t *testing.T, actualCalls []string, expectedCalls []string) { - actualCount := len(actualCalls) - expectedCount := len(expectedCalls) - - if actualCount != expectedCount { - t.Errorf("Actual calls: %v", actualCalls) - t.Errorf("Expected calls: %v", expectedCalls) - t.Errorf("Call count error: %d != %d", actualCount, expectedCount) - return - } - - for i, v := range actualCalls { - if v != expectedCalls[i] { - t.Errorf("Actual calls: %v", actualCalls) - t.Errorf("Expected calls: %v", expectedCalls) - t.Errorf("Mismatched calls: %s != %s with lengths %d and %d", v, expectedCalls[i], len(v), len(expectedCalls[i])) - } - } -} - -func fillContext(context *AnsiContext) { - context.currentChar = 'A' - context.paramBuffer = []byte{'C', 'D', 'E'} - context.interBuffer = []byte{'F', 'G', 'H'} -} - -func validateEmptyContext(t *testing.T, context *AnsiContext) { - var expectedCurrChar byte = 0x0 - if context.currentChar != expectedCurrChar { - t.Errorf("Currentchar mismatch '%#x' != '%#x'", context.currentChar, expectedCurrChar) - } - - if len(context.paramBuffer) != 0 { - t.Errorf("Non-empty parameter buffer: %v", context.paramBuffer) - } - - if len(context.paramBuffer) != 0 { - t.Errorf("Non-empty intermediate buffer: %v", context.interBuffer) - } - -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/states.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/states.go index 0cbdcb3c83..f2ea1fcd12 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/states.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/states.go @@ -1,52 +1,52 @@ package ansiterm -type StateId int +type stateID int -type State interface { +type state interface { Enter() error Exit() error - Handle(byte) (State, error) + Handle(byte) (state, error) Name() string - Transition(State) error + Transition(state) error } -type BaseState struct { +type baseState struct { name string parser *AnsiParser } -func (base BaseState) Enter() error { +func (base baseState) Enter() error { return nil } -func (base BaseState) Exit() error { +func (base baseState) Exit() error { return nil } -func (base BaseState) Handle(b byte) (s State, e error) { +func (base baseState) Handle(b byte) (s state, e error) { switch { case b == CSI_ENTRY: - return base.parser.CsiEntry, nil + return base.parser.csiEntry, nil case b == DCS_ENTRY: - return base.parser.DcsEntry, nil + return base.parser.dcsEntry, nil case b == ANSI_ESCAPE_PRIMARY: - return base.parser.Escape, nil + return base.parser.escape, nil case b == OSC_STRING: - return base.parser.OscString, nil - case sliceContains(ToGroundBytes, b): - return base.parser.Ground, nil + return base.parser.oscString, nil + case sliceContains(toGroundBytes, b): + return base.parser.ground, nil } return nil, nil } -func (base BaseState) Name() string { +func (base baseState) Name() string { return base.name } -func (base BaseState) Transition(s State) error { - if s == base.parser.Ground { +func (base baseState) Transition(s state) error { + if s == base.parser.ground { execBytes := []byte{0x18} execBytes = append(execBytes, 0x1A) execBytes = append(execBytes, getByteRange(0x80, 0x8F)...) @@ -62,10 +62,10 @@ func (base BaseState) Transition(s State) error { return nil } -type DcsEntryState struct { - BaseState +type dcsEntryState struct { + baseState } -type ErrorState struct { - BaseState +type errorState struct { + baseState } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/test_event_handler.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/test_event_handler.go deleted file mode 100644 index 60f9f30b98..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/test_event_handler.go +++ /dev/null @@ -1,173 +0,0 @@ -package ansiterm - -import ( - "fmt" - "strconv" -) - -type TestAnsiEventHandler struct { - FunctionCalls []string -} - -func CreateTestAnsiEventHandler() *TestAnsiEventHandler { - evtHandler := TestAnsiEventHandler{} - evtHandler.FunctionCalls = make([]string, 0) - return &evtHandler -} - -func (h *TestAnsiEventHandler) recordCall(call string, params []string) { - s := fmt.Sprintf("%s(%v)", call, params) - h.FunctionCalls = append(h.FunctionCalls, s) -} - -func (h *TestAnsiEventHandler) Print(b byte) error { - h.recordCall("Print", []string{string(b)}) - return nil -} - -func (h *TestAnsiEventHandler) Execute(b byte) error { - h.recordCall("Execute", []string{string(b)}) - return nil -} - -func (h *TestAnsiEventHandler) CUU(param int) error { - h.recordCall("CUU", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CUD(param int) error { - h.recordCall("CUD", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CUF(param int) error { - h.recordCall("CUF", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CUB(param int) error { - h.recordCall("CUB", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CNL(param int) error { - h.recordCall("CNL", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CPL(param int) error { - h.recordCall("CPL", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CHA(param int) error { - h.recordCall("CHA", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) VPA(param int) error { - h.recordCall("VPA", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) CUP(x int, y int) error { - xS, yS := strconv.Itoa(x), strconv.Itoa(y) - h.recordCall("CUP", []string{xS, yS}) - return nil -} - -func (h *TestAnsiEventHandler) HVP(x int, y int) error { - xS, yS := strconv.Itoa(x), strconv.Itoa(y) - h.recordCall("HVP", []string{xS, yS}) - return nil -} - -func (h *TestAnsiEventHandler) DECTCEM(visible bool) error { - h.recordCall("DECTCEM", []string{strconv.FormatBool(visible)}) - return nil -} - -func (h *TestAnsiEventHandler) DECOM(visible bool) error { - h.recordCall("DECOM", []string{strconv.FormatBool(visible)}) - return nil -} - -func (h *TestAnsiEventHandler) DECCOLM(use132 bool) error { - h.recordCall("DECOLM", []string{strconv.FormatBool(use132)}) - return nil -} - -func (h *TestAnsiEventHandler) ED(param int) error { - h.recordCall("ED", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) EL(param int) error { - h.recordCall("EL", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) IL(param int) error { - h.recordCall("IL", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) DL(param int) error { - h.recordCall("DL", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) ICH(param int) error { - h.recordCall("ICH", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) DCH(param int) error { - h.recordCall("DCH", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) SGR(params []int) error { - strings := []string{} - for _, v := range params { - strings = append(strings, strconv.Itoa(v)) - } - - h.recordCall("SGR", strings) - return nil -} - -func (h *TestAnsiEventHandler) SU(param int) error { - h.recordCall("SU", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) SD(param int) error { - h.recordCall("SD", []string{strconv.Itoa(param)}) - return nil -} - -func (h *TestAnsiEventHandler) DA(params []string) error { - h.recordCall("DA", params) - return nil -} - -func (h *TestAnsiEventHandler) DECSTBM(top int, bottom int) error { - topS, bottomS := strconv.Itoa(top), strconv.Itoa(bottom) - h.recordCall("DECSTBM", []string{topS, bottomS}) - return nil -} - -func (h *TestAnsiEventHandler) RI() error { - h.recordCall("RI", nil) - return nil -} - -func (h *TestAnsiEventHandler) IND() error { - h.recordCall("IND", nil) - return nil -} - -func (h *TestAnsiEventHandler) Flush() error { - return nil -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/ansi.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/ansi.go index 78fe92fe65..daf2f06961 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/ansi.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/ansi.go @@ -9,7 +9,7 @@ import ( "strings" "syscall" - . "github.com/Azure/go-ansiterm" + "github.com/Azure/go-ansiterm" ) // Windows keyboard constants @@ -85,17 +85,17 @@ func newAnsiCommand(command []byte) *ansiCommand { if lastCharIndex != 0 { start := 1 // skip if double char escape sequence - if command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_ESCAPE_SECONDARY { + if command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_ESCAPE_SECONDARY { start++ } // convert this to GetNextParam method - ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ANSI_PARAMETER_SEP) + ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ansiterm.ANSI_PARAMETER_SEP) } return ac } -func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT { +func (ac *ansiCommand) paramAsSHORT(index int, defaultValue int16) int16 { if index < 0 || index >= len(ac.Parameters) { return defaultValue } @@ -105,7 +105,7 @@ func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT { return defaultValue } - return SHORT(param) + return int16(param) } func (ac *ansiCommand) String() string { @@ -119,12 +119,12 @@ func (ac *ansiCommand) String() string { // See http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html. func isAnsiCommandChar(b byte) bool { switch { - case ANSI_COMMAND_FIRST <= b && b <= ANSI_COMMAND_LAST && b != ANSI_ESCAPE_SECONDARY: + case ansiterm.ANSI_COMMAND_FIRST <= b && b <= ansiterm.ANSI_COMMAND_LAST && b != ansiterm.ANSI_ESCAPE_SECONDARY: return true - case b == ANSI_CMD_G1 || b == ANSI_CMD_OSC || b == ANSI_CMD_DECPAM || b == ANSI_CMD_DECPNM: + case b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_OSC || b == ansiterm.ANSI_CMD_DECPAM || b == ansiterm.ANSI_CMD_DECPNM: // non-CSI escape sequence terminator return true - case b == ANSI_CMD_STR_TERM || b == ANSI_BEL: + case b == ansiterm.ANSI_CMD_STR_TERM || b == ansiterm.ANSI_BEL: // String escape sequence terminator return true } @@ -132,11 +132,11 @@ func isAnsiCommandChar(b byte) bool { } func isXtermOscSequence(command []byte, current byte) bool { - return (len(command) >= 2 && command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_CMD_OSC && current != ANSI_BEL) + return (len(command) >= 2 && command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_CMD_OSC && current != ansiterm.ANSI_BEL) } func isCharacterSelectionCmdChar(b byte) bool { - return (b == ANSI_CMD_G0 || b == ANSI_CMD_G1 || b == ANSI_CMD_G2 || b == ANSI_CMD_G3) + return (b == ansiterm.ANSI_CMD_G0 || b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_G2 || b == ansiterm.ANSI_CMD_G3) } // bytesToHex converts a slice of bytes to a human-readable string. @@ -150,7 +150,7 @@ func bytesToHex(b []byte) string { // ensureInRange adjusts the passed value, if necessary, to ensure it is within // the passed min / max range. -func ensureInRange(n SHORT, min SHORT, max SHORT) SHORT { +func ensureInRange(n int16, min int16, max int16) int16 { if n < min { return min } else if n > max { diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/api.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/api.go index 1f2f3853cc..462d92f8ef 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/api.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/api.go @@ -66,21 +66,21 @@ const ( // -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan). // Clearing all foreground or background colors results in black; setting all creates white. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes. - FOREGROUND_BLUE WORD = 0x0001 - FOREGROUND_GREEN WORD = 0x0002 - FOREGROUND_RED WORD = 0x0004 - FOREGROUND_INTENSITY WORD = 0x0008 - FOREGROUND_MASK WORD = 0x000F + FOREGROUND_BLUE uint16 = 0x0001 + FOREGROUND_GREEN uint16 = 0x0002 + FOREGROUND_RED uint16 = 0x0004 + FOREGROUND_INTENSITY uint16 = 0x0008 + FOREGROUND_MASK uint16 = 0x000F - BACKGROUND_BLUE WORD = 0x0010 - BACKGROUND_GREEN WORD = 0x0020 - BACKGROUND_RED WORD = 0x0040 - BACKGROUND_INTENSITY WORD = 0x0080 - BACKGROUND_MASK WORD = 0x00F0 + BACKGROUND_BLUE uint16 = 0x0010 + BACKGROUND_GREEN uint16 = 0x0020 + BACKGROUND_RED uint16 = 0x0040 + BACKGROUND_INTENSITY uint16 = 0x0080 + BACKGROUND_MASK uint16 = 0x00F0 - COMMON_LVB_MASK WORD = 0xFF00 - COMMON_LVB_REVERSE_VIDEO WORD = 0x4000 - COMMON_LVB_UNDERSCORE WORD = 0x8000 + COMMON_LVB_MASK uint16 = 0xFF00 + COMMON_LVB_REVERSE_VIDEO uint16 = 0x4000 + COMMON_LVB_UNDERSCORE uint16 = 0x8000 // Input event types // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx. @@ -104,60 +104,53 @@ const ( ) // Windows API Console types -// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx for core types (e.g., SHORT) // -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) // -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment type ( - SHORT int16 - BOOL int32 - WORD uint16 - WCHAR uint16 - DWORD uint32 - CHAR_INFO struct { - UnicodeChar WCHAR - Attributes WORD + UnicodeChar uint16 + Attributes uint16 } CONSOLE_CURSOR_INFO struct { - Size DWORD - Visible BOOL + Size uint32 + Visible int32 } CONSOLE_SCREEN_BUFFER_INFO struct { Size COORD CursorPosition COORD - Attributes WORD + Attributes uint16 Window SMALL_RECT MaximumWindowSize COORD } COORD struct { - X SHORT - Y SHORT + X int16 + Y int16 } SMALL_RECT struct { - Left SHORT - Top SHORT - Right SHORT - Bottom SHORT + Left int16 + Top int16 + Right int16 + Bottom int16 } // INPUT_RECORD is a C/C++ union of which KEY_EVENT_RECORD is one case, it is also the largest // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx. INPUT_RECORD struct { - EventType WORD + EventType uint16 KeyEvent KEY_EVENT_RECORD } KEY_EVENT_RECORD struct { - KeyDown BOOL - RepeatCount WORD - VirtualKeyCode WORD - VirtualScanCode WORD - UnicodeChar WCHAR - ControlKeyState DWORD + KeyDown int32 + RepeatCount uint16 + VirtualKeyCode uint16 + VirtualScanCode uint16 + UnicodeChar uint16 + ControlKeyState uint32 } WINDOW_BUFFER_SIZE struct { @@ -165,12 +158,12 @@ type ( } ) -// boolToBOOL converts a Go bool into a Windows BOOL. -func boolToBOOL(f bool) BOOL { +// boolToBOOL converts a Go bool into a Windows int32. +func boolToBOOL(f bool) int32 { if f { - return BOOL(1) + return int32(1) } else { - return BOOL(0) + return int32(0) } } @@ -242,7 +235,7 @@ func SetConsoleScreenBufferSize(handle uintptr, coord COORD) error { // SetConsoleTextAttribute sets the attributes of characters written to the // console screen buffer by the WriteFile or WriteConsole function. // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx. -func SetConsoleTextAttribute(handle uintptr, attribute WORD) error { +func SetConsoleTextAttribute(handle uintptr, attribute uint16) error { r1, r2, err := setConsoleTextAttributeProc.Call(handle, uintptr(attribute), 0) use(attribute) return checkError(r1, r2, err) @@ -280,7 +273,7 @@ func ReadConsoleInput(handle uintptr, buffer []INPUT_RECORD, count *uint32) erro // It returns true if the handle was signaled; false otherwise. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx. func WaitForSingleObject(handle uintptr, msWait uint32) (bool, error) { - r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(DWORD(msWait))) + r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(uint32(msWait))) switch r1 { case WAIT_ABANDONED, WAIT_TIMEOUT: return false, nil @@ -320,8 +313,8 @@ func checkError(r1, r2 uintptr, err error) error { // coordToPointer converts a COORD into a uintptr (by fooling the type system). func coordToPointer(c COORD) uintptr { - // Note: This code assumes the two SHORTs are correctly laid out; the "cast" to DWORD is just to get a pointer to pass. - return uintptr(*((*DWORD)(unsafe.Pointer(&c)))) + // Note: This code assumes the two SHORTs are correctly laid out; the "cast" to uint32 is just to get a pointer to pass. + return uintptr(*((*uint32)(unsafe.Pointer(&c)))) } // use is a no-op, but the compiler cannot see that it is. diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/attr_translation.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/attr_translation.go index 94665db6fb..cbec8f728f 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/attr_translation.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/attr_translation.go @@ -2,9 +2,7 @@ package winterm -import ( - . "github.com/Azure/go-ansiterm" -) +import "github.com/Azure/go-ansiterm" const ( FOREGROUND_COLOR_MASK = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE @@ -13,83 +11,83 @@ const ( // collectAnsiIntoWindowsAttributes modifies the passed Windows text mode flags to reflect the // request represented by the passed ANSI mode. -func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode WORD, ansiMode SHORT) (WORD, bool) { +func collectAnsiIntoWindowsAttributes(windowsMode uint16, inverted bool, baseMode uint16, ansiMode int16) (uint16, bool) { switch ansiMode { // Mode styles - case ANSI_SGR_BOLD: + case ansiterm.ANSI_SGR_BOLD: windowsMode = windowsMode | FOREGROUND_INTENSITY - case ANSI_SGR_DIM, ANSI_SGR_BOLD_DIM_OFF: + case ansiterm.ANSI_SGR_DIM, ansiterm.ANSI_SGR_BOLD_DIM_OFF: windowsMode &^= FOREGROUND_INTENSITY - case ANSI_SGR_UNDERLINE: + case ansiterm.ANSI_SGR_UNDERLINE: windowsMode = windowsMode | COMMON_LVB_UNDERSCORE - case ANSI_SGR_REVERSE: + case ansiterm.ANSI_SGR_REVERSE: inverted = true - case ANSI_SGR_REVERSE_OFF: + case ansiterm.ANSI_SGR_REVERSE_OFF: inverted = false - case ANSI_SGR_UNDERLINE_OFF: + case ansiterm.ANSI_SGR_UNDERLINE_OFF: windowsMode &^= COMMON_LVB_UNDERSCORE // Foreground colors - case ANSI_SGR_FOREGROUND_DEFAULT: + case ansiterm.ANSI_SGR_FOREGROUND_DEFAULT: windowsMode = (windowsMode &^ FOREGROUND_MASK) | (baseMode & FOREGROUND_MASK) - case ANSI_SGR_FOREGROUND_BLACK: + case ansiterm.ANSI_SGR_FOREGROUND_BLACK: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) - case ANSI_SGR_FOREGROUND_RED: + case ansiterm.ANSI_SGR_FOREGROUND_RED: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED - case ANSI_SGR_FOREGROUND_GREEN: + case ansiterm.ANSI_SGR_FOREGROUND_GREEN: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN - case ANSI_SGR_FOREGROUND_YELLOW: + case ansiterm.ANSI_SGR_FOREGROUND_YELLOW: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN - case ANSI_SGR_FOREGROUND_BLUE: + case ansiterm.ANSI_SGR_FOREGROUND_BLUE: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_BLUE - case ANSI_SGR_FOREGROUND_MAGENTA: + case ansiterm.ANSI_SGR_FOREGROUND_MAGENTA: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_BLUE - case ANSI_SGR_FOREGROUND_CYAN: + case ansiterm.ANSI_SGR_FOREGROUND_CYAN: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE - case ANSI_SGR_FOREGROUND_WHITE: + case ansiterm.ANSI_SGR_FOREGROUND_WHITE: windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE // Background colors - case ANSI_SGR_BACKGROUND_DEFAULT: + case ansiterm.ANSI_SGR_BACKGROUND_DEFAULT: // Black with no intensity windowsMode = (windowsMode &^ BACKGROUND_MASK) | (baseMode & BACKGROUND_MASK) - case ANSI_SGR_BACKGROUND_BLACK: + case ansiterm.ANSI_SGR_BACKGROUND_BLACK: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) - case ANSI_SGR_BACKGROUND_RED: + case ansiterm.ANSI_SGR_BACKGROUND_RED: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED - case ANSI_SGR_BACKGROUND_GREEN: + case ansiterm.ANSI_SGR_BACKGROUND_GREEN: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN - case ANSI_SGR_BACKGROUND_YELLOW: + case ansiterm.ANSI_SGR_BACKGROUND_YELLOW: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN - case ANSI_SGR_BACKGROUND_BLUE: + case ansiterm.ANSI_SGR_BACKGROUND_BLUE: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_BLUE - case ANSI_SGR_BACKGROUND_MAGENTA: + case ansiterm.ANSI_SGR_BACKGROUND_MAGENTA: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_BLUE - case ANSI_SGR_BACKGROUND_CYAN: + case ansiterm.ANSI_SGR_BACKGROUND_CYAN: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE - case ANSI_SGR_BACKGROUND_WHITE: + case ansiterm.ANSI_SGR_BACKGROUND_WHITE: windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE } @@ -97,6 +95,6 @@ func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode } // invertAttributes inverts the foreground and background colors of a Windows attributes value -func invertAttributes(windowsMode WORD) WORD { +func invertAttributes(windowsMode uint16) uint16 { return (COMMON_LVB_MASK & windowsMode) | ((FOREGROUND_MASK & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4) } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/cursor_helpers.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/cursor_helpers.go index e4b1c255a4..f015723ade 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/cursor_helpers.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/cursor_helpers.go @@ -3,11 +3,11 @@ package winterm const ( - Horizontal = iota - Vertical + horizontal = iota + vertical ) -func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT { +func (h *windowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT { if h.originMode { sr := h.effectiveSr(info.Window) return SMALL_RECT{ @@ -27,7 +27,7 @@ func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_IN } // setCursorPosition sets the cursor to the specified position, bounded to the screen size -func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error { +func (h *windowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error { position.X = ensureInRange(position.X, window.Left, window.Right) position.Y = ensureInRange(position.Y, window.Top, window.Bottom) err := SetConsoleCursorPosition(h.fd, position) @@ -38,15 +38,15 @@ func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL return err } -func (h *WindowsAnsiEventHandler) moveCursorVertical(param int) error { - return h.moveCursor(Vertical, param) +func (h *windowsAnsiEventHandler) moveCursorVertical(param int) error { + return h.moveCursor(vertical, param) } -func (h *WindowsAnsiEventHandler) moveCursorHorizontal(param int) error { - return h.moveCursor(Horizontal, param) +func (h *windowsAnsiEventHandler) moveCursorHorizontal(param int) error { + return h.moveCursor(horizontal, param) } -func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error { +func (h *windowsAnsiEventHandler) moveCursor(moveMode int, param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err @@ -54,10 +54,10 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error { position := info.CursorPosition switch moveMode { - case Horizontal: - position.X += SHORT(param) - case Vertical: - position.Y += SHORT(param) + case horizontal: + position.X += int16(param) + case vertical: + position.Y += int16(param) } if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { @@ -67,7 +67,7 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error { return nil } -func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error { +func (h *windowsAnsiEventHandler) moveCursorLine(param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err @@ -75,7 +75,7 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error { position := info.CursorPosition position.X = 0 - position.Y += SHORT(param) + position.Y += int16(param) if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { return err @@ -84,14 +84,14 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error { return nil } -func (h *WindowsAnsiEventHandler) moveCursorColumn(param int) error { +func (h *windowsAnsiEventHandler) moveCursorColumn(param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err } position := info.CursorPosition - position.X = SHORT(param) - 1 + position.X = int16(param) - 1 if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { return err diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/erase_helpers.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/erase_helpers.go index f02a5b261b..244b5fa25e 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/erase_helpers.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/erase_helpers.go @@ -2,11 +2,9 @@ package winterm -import ( - . "github.com/Azure/go-ansiterm" -) +import "github.com/Azure/go-ansiterm" -func (h *WindowsAnsiEventHandler) clearRange(attributes WORD, fromCoord COORD, toCoord COORD) error { +func (h *windowsAnsiEventHandler) clearRange(attributes uint16, fromCoord COORD, toCoord COORD) error { // Ignore an invalid (negative area) request if toCoord.Y < fromCoord.Y { return nil @@ -60,7 +58,7 @@ func (h *WindowsAnsiEventHandler) clearRange(attributes WORD, fromCoord COORD, t return nil } -func (h *WindowsAnsiEventHandler) clearRect(attributes WORD, fromCoord COORD, toCoord COORD) error { +func (h *windowsAnsiEventHandler) clearRect(attributes uint16, fromCoord COORD, toCoord COORD) error { region := SMALL_RECT{Top: fromCoord.Y, Left: fromCoord.X, Bottom: toCoord.Y, Right: toCoord.X} width := toCoord.X - fromCoord.X + 1 height := toCoord.Y - fromCoord.Y + 1 @@ -72,7 +70,7 @@ func (h *WindowsAnsiEventHandler) clearRect(attributes WORD, fromCoord COORD, to buffer := make([]CHAR_INFO, size) - char := CHAR_INFO{WCHAR(FILL_CHARACTER), attributes} + char := CHAR_INFO{ansiterm.FILL_CHARACTER, attributes} for i := 0; i < int(size); i++ { buffer[i] = char } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/scroll_helper.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/scroll_helper.go index ed1998245c..706d270577 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/scroll_helper.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/scroll_helper.go @@ -3,9 +3,9 @@ package winterm // effectiveSr gets the current effective scroll region in buffer coordinates -func (h *WindowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion { - top := AddInRange(window.Top, h.sr.top, window.Top, window.Bottom) - bottom := AddInRange(window.Top, h.sr.bottom, window.Top, window.Bottom) +func (h *windowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion { + top := addInRange(window.Top, h.sr.top, window.Top, window.Bottom) + bottom := addInRange(window.Top, h.sr.bottom, window.Top, window.Bottom) if top >= bottom { top = window.Top bottom = window.Bottom @@ -13,7 +13,7 @@ func (h *WindowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion { return scrollRegion{top: top, bottom: bottom} } -func (h *WindowsAnsiEventHandler) scrollUp(param int) error { +func (h *windowsAnsiEventHandler) scrollUp(param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err @@ -23,11 +23,11 @@ func (h *WindowsAnsiEventHandler) scrollUp(param int) error { return h.scroll(param, sr, info) } -func (h *WindowsAnsiEventHandler) scrollDown(param int) error { +func (h *windowsAnsiEventHandler) scrollDown(param int) error { return h.scrollUp(-param) } -func (h *WindowsAnsiEventHandler) deleteLines(param int) error { +func (h *windowsAnsiEventHandler) deleteLines(param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err @@ -44,12 +44,12 @@ func (h *WindowsAnsiEventHandler) deleteLines(param int) error { } } -func (h *WindowsAnsiEventHandler) insertLines(param int) error { +func (h *windowsAnsiEventHandler) insertLines(param int) error { return h.deleteLines(-param) } // scroll scrolls the provided scroll region by param lines. The scroll region is in buffer coordinates. -func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSOLE_SCREEN_BUFFER_INFO) error { +func (h *windowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSOLE_SCREEN_BUFFER_INFO) error { logger.Infof("scroll: scrollTop: %d, scrollBottom: %d", sr.top, sr.bottom) logger.Infof("scroll: windowTop: %d, windowBottom: %d", info.Window.Top, info.Window.Bottom) @@ -64,7 +64,7 @@ func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSO // Origin to which area should be copied destOrigin := COORD{ X: 0, - Y: sr.top - SHORT(param), + Y: sr.top - int16(param), } char := CHAR_INFO{ @@ -78,7 +78,7 @@ func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSO return nil } -func (h *WindowsAnsiEventHandler) deleteCharacters(param int) error { +func (h *windowsAnsiEventHandler) deleteCharacters(param int) error { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { return err @@ -86,12 +86,12 @@ func (h *WindowsAnsiEventHandler) deleteCharacters(param int) error { return h.scrollLine(param, info.CursorPosition, info) } -func (h *WindowsAnsiEventHandler) insertCharacters(param int) error { +func (h *windowsAnsiEventHandler) insertCharacters(param int) error { return h.deleteCharacters(-param) } // scrollLine scrolls a line horizontally starting at the provided position by a number of columns. -func (h *WindowsAnsiEventHandler) scrollLine(columns int, position COORD, info *CONSOLE_SCREEN_BUFFER_INFO) error { +func (h *windowsAnsiEventHandler) scrollLine(columns int, position COORD, info *CONSOLE_SCREEN_BUFFER_INFO) error { // Copy from and clip to the scroll region (full buffer width) scrollRect := SMALL_RECT{ Top: position.Y, @@ -102,7 +102,7 @@ func (h *WindowsAnsiEventHandler) scrollLine(columns int, position COORD, info * // Origin to which area should be copied destOrigin := COORD{ - X: position.X - SHORT(columns), + X: position.X - int16(columns), Y: position.Y, } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/utilities.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/utilities.go index 2f963ff132..afa7635d77 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/utilities.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/utilities.go @@ -4,6 +4,6 @@ package winterm // AddInRange increments a value by the passed quantity while ensuring the values // always remain within the supplied min / max range. -func AddInRange(n SHORT, increment SHORT, min SHORT, max SHORT) SHORT { +func addInRange(n int16, increment int16, min int16, max int16) int16 { return ensureInRange(n+increment, min, max) } diff --git a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/win_event_handler.go b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/win_event_handler.go index 2d492b32e4..4d858ed611 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/win_event_handler.go +++ b/libnetwork/Godeps/_workspace/src/github.com/Azure/go-ansiterm/winterm/win_event_handler.go @@ -8,19 +8,19 @@ import ( "os" "strconv" - . "github.com/Azure/go-ansiterm" + "github.com/Azure/go-ansiterm" "github.com/Sirupsen/logrus" ) var logger *logrus.Logger -type WindowsAnsiEventHandler struct { +type windowsAnsiEventHandler struct { fd uintptr file *os.File infoReset *CONSOLE_SCREEN_BUFFER_INFO sr scrollRegion buffer bytes.Buffer - attributes WORD + attributes uint16 inverted bool wrapNext bool drewMarginByte bool @@ -30,10 +30,10 @@ type WindowsAnsiEventHandler struct { curPos COORD } -func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler { +func CreateWinEventHandler(fd uintptr, file *os.File) ansiterm.AnsiEventHandler { logFile := ioutil.Discard - if isDebugEnv := os.Getenv(LogEnv); isDebugEnv == "1" { + if isDebugEnv := os.Getenv(ansiterm.LogEnv); isDebugEnv == "1" { logFile, _ = os.Create("winEventHandler.log") } @@ -48,7 +48,7 @@ func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler { return nil } - return &WindowsAnsiEventHandler{ + return &windowsAnsiEventHandler{ fd: fd, file: file, infoReset: infoReset, @@ -57,8 +57,8 @@ func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler { } type scrollRegion struct { - top SHORT - bottom SHORT + top int16 + bottom int16 } // simulateLF simulates a LF or CR+LF by scrolling if necessary to handle the @@ -68,7 +68,7 @@ type scrollRegion struct { // // In the false case, the caller should ensure that a carriage return // and line feed are inserted or that the text is otherwise wrapped. -func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { +func (h *windowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { if h.wrapNext { if err := h.Flush(); err != nil { return false, err @@ -89,24 +89,25 @@ func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { h.updatePos(pos) } return false, nil - } else { - // A custom scroll region is active. Scroll the window manually to simulate - // the LF. - if err := h.Flush(); err != nil { - return false, err - } - logger.Info("Simulating LF inside scroll region") - if err := h.scrollUp(1); err != nil { - return false, err - } - if includeCR { - pos.X = 0 - if err := SetConsoleCursorPosition(h.fd, pos); err != nil { - return false, err - } - } - return true, nil } + + // A custom scroll region is active. Scroll the window manually to simulate + // the LF. + if err := h.Flush(); err != nil { + return false, err + } + logger.Info("Simulating LF inside scroll region") + if err := h.scrollUp(1); err != nil { + return false, err + } + if includeCR { + pos.X = 0 + if err := SetConsoleCursorPosition(h.fd, pos); err != nil { + return false, err + } + } + return true, nil + } else if pos.Y < info.Window.Bottom { // Let Windows handle the LF. pos.Y++ @@ -133,7 +134,7 @@ func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { } // executeLF executes a LF without a CR. -func (h *WindowsAnsiEventHandler) executeLF() error { +func (h *windowsAnsiEventHandler) executeLF() error { handled, err := h.simulateLF(false) if err != nil { return err @@ -145,7 +146,7 @@ func (h *WindowsAnsiEventHandler) executeLF() error { if err != nil { return err } - h.buffer.WriteByte(ANSI_LINE_FEED) + h.buffer.WriteByte(ansiterm.ANSI_LINE_FEED) if pos.X != 0 { if err := h.Flush(); err != nil { return err @@ -159,7 +160,7 @@ func (h *WindowsAnsiEventHandler) executeLF() error { return nil } -func (h *WindowsAnsiEventHandler) Print(b byte) error { +func (h *windowsAnsiEventHandler) Print(b byte) error { if h.wrapNext { h.buffer.WriteByte(h.marginByte) h.clearWrap() @@ -182,9 +183,9 @@ func (h *WindowsAnsiEventHandler) Print(b byte) error { return nil } -func (h *WindowsAnsiEventHandler) Execute(b byte) error { +func (h *windowsAnsiEventHandler) Execute(b byte) error { switch b { - case ANSI_TAB: + case ansiterm.ANSI_TAB: logger.Info("Execute(TAB)") // Move to the next tab stop, but preserve auto-wrap if already set. if !h.wrapNext { @@ -205,11 +206,11 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error { } return nil - case ANSI_BEL: - h.buffer.WriteByte(ANSI_BEL) + case ansiterm.ANSI_BEL: + h.buffer.WriteByte(ansiterm.ANSI_BEL) return nil - case ANSI_BACKSPACE: + case ansiterm.ANSI_BACKSPACE: if h.wrapNext { if err := h.Flush(); err != nil { return err @@ -223,15 +224,15 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error { if pos.X > 0 { pos.X-- h.updatePos(pos) - h.buffer.WriteByte(ANSI_BACKSPACE) + h.buffer.WriteByte(ansiterm.ANSI_BACKSPACE) } return nil - case ANSI_VERTICAL_TAB, ANSI_FORM_FEED: + case ansiterm.ANSI_VERTICAL_TAB, ansiterm.ANSI_FORM_FEED: // Treat as true LF. return h.executeLF() - case ANSI_LINE_FEED: + case ansiterm.ANSI_LINE_FEED: // Simulate a CR and LF for now since there is no way in go-ansiterm // to tell if the LF should include CR (and more things break when it's // missing than when it's incorrectly added). @@ -239,9 +240,9 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error { if handled || err != nil { return err } - return h.buffer.WriteByte(ANSI_LINE_FEED) + return h.buffer.WriteByte(ansiterm.ANSI_LINE_FEED) - case ANSI_CARRIAGE_RETURN: + case ansiterm.ANSI_CARRIAGE_RETURN: if h.wrapNext { if err := h.Flush(); err != nil { return err @@ -255,7 +256,7 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error { if pos.X != 0 { pos.X = 0 h.updatePos(pos) - h.buffer.WriteByte(ANSI_CARRIAGE_RETURN) + h.buffer.WriteByte(ansiterm.ANSI_CARRIAGE_RETURN) } return nil @@ -264,7 +265,7 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error { } } -func (h *WindowsAnsiEventHandler) CUU(param int) error { +func (h *windowsAnsiEventHandler) CUU(param int) error { if err := h.Flush(); err != nil { return err } @@ -273,7 +274,7 @@ func (h *WindowsAnsiEventHandler) CUU(param int) error { return h.moveCursorVertical(-param) } -func (h *WindowsAnsiEventHandler) CUD(param int) error { +func (h *windowsAnsiEventHandler) CUD(param int) error { if err := h.Flush(); err != nil { return err } @@ -282,7 +283,7 @@ func (h *WindowsAnsiEventHandler) CUD(param int) error { return h.moveCursorVertical(param) } -func (h *WindowsAnsiEventHandler) CUF(param int) error { +func (h *windowsAnsiEventHandler) CUF(param int) error { if err := h.Flush(); err != nil { return err } @@ -291,7 +292,7 @@ func (h *WindowsAnsiEventHandler) CUF(param int) error { return h.moveCursorHorizontal(param) } -func (h *WindowsAnsiEventHandler) CUB(param int) error { +func (h *windowsAnsiEventHandler) CUB(param int) error { if err := h.Flush(); err != nil { return err } @@ -300,7 +301,7 @@ func (h *WindowsAnsiEventHandler) CUB(param int) error { return h.moveCursorHorizontal(-param) } -func (h *WindowsAnsiEventHandler) CNL(param int) error { +func (h *windowsAnsiEventHandler) CNL(param int) error { if err := h.Flush(); err != nil { return err } @@ -309,7 +310,7 @@ func (h *WindowsAnsiEventHandler) CNL(param int) error { return h.moveCursorLine(param) } -func (h *WindowsAnsiEventHandler) CPL(param int) error { +func (h *windowsAnsiEventHandler) CPL(param int) error { if err := h.Flush(); err != nil { return err } @@ -318,7 +319,7 @@ func (h *WindowsAnsiEventHandler) CPL(param int) error { return h.moveCursorLine(-param) } -func (h *WindowsAnsiEventHandler) CHA(param int) error { +func (h *windowsAnsiEventHandler) CHA(param int) error { if err := h.Flush(); err != nil { return err } @@ -327,7 +328,7 @@ func (h *WindowsAnsiEventHandler) CHA(param int) error { return h.moveCursorColumn(param) } -func (h *WindowsAnsiEventHandler) VPA(param int) error { +func (h *windowsAnsiEventHandler) VPA(param int) error { if err := h.Flush(); err != nil { return err } @@ -339,11 +340,11 @@ func (h *WindowsAnsiEventHandler) VPA(param int) error { } window := h.getCursorWindow(info) position := info.CursorPosition - position.Y = window.Top + SHORT(param) - 1 + position.Y = window.Top + int16(param) - 1 return h.setCursorPosition(position, window) } -func (h *WindowsAnsiEventHandler) CUP(row int, col int) error { +func (h *windowsAnsiEventHandler) CUP(row int, col int) error { if err := h.Flush(); err != nil { return err } @@ -355,11 +356,11 @@ func (h *WindowsAnsiEventHandler) CUP(row int, col int) error { } window := h.getCursorWindow(info) - position := COORD{window.Left + SHORT(col) - 1, window.Top + SHORT(row) - 1} + position := COORD{window.Left + int16(col) - 1, window.Top + int16(row) - 1} return h.setCursorPosition(position, window) } -func (h *WindowsAnsiEventHandler) HVP(row int, col int) error { +func (h *windowsAnsiEventHandler) HVP(row int, col int) error { if err := h.Flush(); err != nil { return err } @@ -368,7 +369,7 @@ func (h *WindowsAnsiEventHandler) HVP(row int, col int) error { return h.CUP(row, col) } -func (h *WindowsAnsiEventHandler) DECTCEM(visible bool) error { +func (h *windowsAnsiEventHandler) DECTCEM(visible bool) error { if err := h.Flush(); err != nil { return err } @@ -377,7 +378,7 @@ func (h *WindowsAnsiEventHandler) DECTCEM(visible bool) error { return nil } -func (h *WindowsAnsiEventHandler) DECOM(enable bool) error { +func (h *windowsAnsiEventHandler) DECOM(enable bool) error { if err := h.Flush(); err != nil { return err } @@ -387,7 +388,7 @@ func (h *WindowsAnsiEventHandler) DECOM(enable bool) error { return h.CUP(1, 1) } -func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error { +func (h *windowsAnsiEventHandler) DECCOLM(use132 bool) error { if err := h.Flush(); err != nil { return err } @@ -400,7 +401,7 @@ func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error { if err != nil { return err } - targetWidth := SHORT(80) + targetWidth := int16(80) if use132 { targetWidth = 132 } @@ -426,7 +427,7 @@ func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error { return SetConsoleCursorPosition(h.fd, COORD{0, 0}) } -func (h *WindowsAnsiEventHandler) ED(param int) error { +func (h *windowsAnsiEventHandler) ED(param int) error { if err := h.Flush(); err != nil { return err } @@ -485,7 +486,7 @@ func (h *WindowsAnsiEventHandler) ED(param int) error { return nil } -func (h *WindowsAnsiEventHandler) EL(param int) error { +func (h *windowsAnsiEventHandler) EL(param int) error { if err := h.Flush(); err != nil { return err } @@ -526,7 +527,7 @@ func (h *WindowsAnsiEventHandler) EL(param int) error { return nil } -func (h *WindowsAnsiEventHandler) IL(param int) error { +func (h *windowsAnsiEventHandler) IL(param int) error { if err := h.Flush(); err != nil { return err } @@ -535,7 +536,7 @@ func (h *WindowsAnsiEventHandler) IL(param int) error { return h.insertLines(param) } -func (h *WindowsAnsiEventHandler) DL(param int) error { +func (h *windowsAnsiEventHandler) DL(param int) error { if err := h.Flush(); err != nil { return err } @@ -544,7 +545,7 @@ func (h *WindowsAnsiEventHandler) DL(param int) error { return h.deleteLines(param) } -func (h *WindowsAnsiEventHandler) ICH(param int) error { +func (h *windowsAnsiEventHandler) ICH(param int) error { if err := h.Flush(); err != nil { return err } @@ -553,7 +554,7 @@ func (h *WindowsAnsiEventHandler) ICH(param int) error { return h.insertCharacters(param) } -func (h *WindowsAnsiEventHandler) DCH(param int) error { +func (h *windowsAnsiEventHandler) DCH(param int) error { if err := h.Flush(); err != nil { return err } @@ -562,7 +563,7 @@ func (h *WindowsAnsiEventHandler) DCH(param int) error { return h.deleteCharacters(param) } -func (h *WindowsAnsiEventHandler) SGR(params []int) error { +func (h *windowsAnsiEventHandler) SGR(params []int) error { if err := h.Flush(); err != nil { return err } @@ -579,13 +580,13 @@ func (h *WindowsAnsiEventHandler) SGR(params []int) error { } else { for _, attr := range params { - if attr == ANSI_SGR_RESET { + if attr == ansiterm.ANSI_SGR_RESET { h.attributes = h.infoReset.Attributes h.inverted = false continue } - h.attributes, h.inverted = collectAnsiIntoWindowsAttributes(h.attributes, h.inverted, h.infoReset.Attributes, SHORT(attr)) + h.attributes, h.inverted = collectAnsiIntoWindowsAttributes(h.attributes, h.inverted, h.infoReset.Attributes, int16(attr)) } } @@ -601,7 +602,7 @@ func (h *WindowsAnsiEventHandler) SGR(params []int) error { return nil } -func (h *WindowsAnsiEventHandler) SU(param int) error { +func (h *windowsAnsiEventHandler) SU(param int) error { if err := h.Flush(); err != nil { return err } @@ -610,7 +611,7 @@ func (h *WindowsAnsiEventHandler) SU(param int) error { return h.scrollUp(param) } -func (h *WindowsAnsiEventHandler) SD(param int) error { +func (h *windowsAnsiEventHandler) SD(param int) error { if err := h.Flush(); err != nil { return err } @@ -619,29 +620,29 @@ func (h *WindowsAnsiEventHandler) SD(param int) error { return h.scrollDown(param) } -func (h *WindowsAnsiEventHandler) DA(params []string) error { +func (h *windowsAnsiEventHandler) DA(params []string) error { logger.Infof("DA: [%v]", params) // DA cannot be implemented because it must send data on the VT100 input stream, // which is not available to go-ansiterm. return nil } -func (h *WindowsAnsiEventHandler) DECSTBM(top int, bottom int) error { +func (h *windowsAnsiEventHandler) DECSTBM(top int, bottom int) error { if err := h.Flush(); err != nil { return err } logger.Infof("DECSTBM: [%d, %d]", top, bottom) // Windows is 0 indexed, Linux is 1 indexed - h.sr.top = SHORT(top - 1) - h.sr.bottom = SHORT(bottom - 1) + h.sr.top = int16(top - 1) + h.sr.bottom = int16(bottom - 1) // This command also moves the cursor to the origin. h.clearWrap() return h.CUP(1, 1) } -func (h *WindowsAnsiEventHandler) RI() error { +func (h *windowsAnsiEventHandler) RI() error { if err := h.Flush(); err != nil { return err } @@ -656,17 +657,17 @@ func (h *WindowsAnsiEventHandler) RI() error { sr := h.effectiveSr(info.Window) if info.CursorPosition.Y == sr.top { return h.scrollDown(1) - } else { - return h.moveCursorVertical(-1) } + + return h.moveCursorVertical(-1) } -func (h *WindowsAnsiEventHandler) IND() error { +func (h *windowsAnsiEventHandler) IND() error { logger.Info("IND: []") return h.executeLF() } -func (h *WindowsAnsiEventHandler) Flush() error { +func (h *windowsAnsiEventHandler) Flush() error { h.curInfo = nil if h.buffer.Len() > 0 { logger.Infof("Flush: [%s]", h.buffer.Bytes()) @@ -683,7 +684,7 @@ func (h *WindowsAnsiEventHandler) Flush() error { return err } - charInfo := []CHAR_INFO{{UnicodeChar: WCHAR(h.marginByte), Attributes: info.Attributes}} + charInfo := []CHAR_INFO{{UnicodeChar: uint16(h.marginByte), Attributes: info.Attributes}} size := COORD{1, 1} position := COORD{0, 0} region := SMALL_RECT{Left: info.CursorPosition.X, Top: info.CursorPosition.Y, Right: info.CursorPosition.X, Bottom: info.CursorPosition.Y} @@ -697,7 +698,7 @@ func (h *WindowsAnsiEventHandler) Flush() error { // cacheConsoleInfo ensures that the current console screen information has been queried // since the last call to Flush(). It must be called before accessing h.curInfo or h.curPos. -func (h *WindowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFER_INFO, error) { +func (h *windowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFER_INFO, error) { if h.curInfo == nil { info, err := GetConsoleScreenBufferInfo(h.fd) if err != nil { @@ -709,7 +710,7 @@ func (h *WindowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFE return h.curPos, h.curInfo, nil } -func (h *WindowsAnsiEventHandler) updatePos(pos COORD) { +func (h *windowsAnsiEventHandler) updatePos(pos COORD) { if h.curInfo == nil { panic("failed to call getCurrentInfo before calling updatePos") } @@ -719,7 +720,7 @@ func (h *WindowsAnsiEventHandler) updatePos(pos COORD) { // clearWrap clears the state where the cursor is in the margin // waiting for the next character before wrapping the line. This must // be done before most operations that act on the cursor. -func (h *WindowsAnsiEventHandler) clearWrap() { +func (h *windowsAnsiEventHandler) clearWrap() { h.wrapNext = false h.drewMarginByte = false } diff --git a/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/.gitignore b/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/.gitignore old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/metrics.go b/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/metrics.go old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/sink.go b/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/sink.go old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/start.go b/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/start.go old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/statsite.go b/libnetwork/Godeps/_workspace/src/github.com/armon/go-metrics/statsite.go old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/bytespipe.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/bytespipe.go index 59bba96265..eca129be39 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/bytespipe.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/bytespipe.go @@ -20,7 +20,8 @@ var ( // ErrClosed is returned when Write is called on a closed BytesPipe. ErrClosed = errors.New("write to closed BytesPipe") - bufPools = make(map[int]*sync.Pool) + bufPools = make(map[int]*sync.Pool) + bufPoolsLock sync.Mutex ) // BytesPipe is io.ReadWriteCloser which works similarly to pipe(queue). @@ -164,17 +165,21 @@ func (bp *BytesPipe) Read(p []byte) (n int, err error) { func returnBuffer(b *fixedBuffer) { b.Reset() + bufPoolsLock.Lock() pool := bufPools[b.Cap()] + bufPoolsLock.Unlock() if pool != nil { pool.Put(b) } } func getBuffer(size int) *fixedBuffer { + bufPoolsLock.Lock() pool, ok := bufPools[size] if !ok { pool = &sync.Pool{New: func() interface{} { return &fixedBuffer{buf: make([]byte, 0, size)} }} bufPools[size] = pool } + bufPoolsLock.Unlock() return pool.Get().(*fixedBuffer) } diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/fswriters.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/fswriters.go new file mode 100644 index 0000000000..ca97670724 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/ioutils/fswriters.go @@ -0,0 +1,75 @@ +package ioutils + +import ( + "io" + "io/ioutil" + "os" + "path/filepath" +) + +// NewAtomicFileWriter returns WriteCloser so that writing to it writes to a +// temporary file and closing it atomically changes the temporary file to +// destination path. Writing and closing concurrently is not allowed. +func NewAtomicFileWriter(filename string, perm os.FileMode) (io.WriteCloser, error) { + f, err := ioutil.TempFile(filepath.Dir(filename), ".tmp-"+filepath.Base(filename)) + if err != nil { + return nil, err + } + abspath, err := filepath.Abs(filename) + if err != nil { + return nil, err + } + return &atomicFileWriter{ + f: f, + fn: abspath, + }, nil +} + +// AtomicWriteFile atomically writes data to a file named by filename. +func AtomicWriteFile(filename string, data []byte, perm os.FileMode) error { + f, err := NewAtomicFileWriter(filename, perm) + if err != nil { + return err + } + n, err := f.Write(data) + if err == nil && n < len(data) { + err = io.ErrShortWrite + } + if err1 := f.Close(); err == nil { + err = err1 + } + return err +} + +type atomicFileWriter struct { + f *os.File + fn string + writeErr error +} + +func (w *atomicFileWriter) Write(dt []byte) (int, error) { + n, err := w.f.Write(dt) + if err != nil { + w.writeErr = err + } + return n, err +} + +func (w *atomicFileWriter) Close() (retErr error) { + defer func() { + if retErr != nil { + os.Remove(w.f.Name()) + } + }() + if err := w.f.Sync(); err != nil { + w.f.Close() + return err + } + if err := w.f.Close(); err != nil { + return err + } + if w.writeErr == nil { + return os.Rename(w.f.Name(), w.fn) + } + return nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/flags_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/flags_unsupported.go index a90d3d1151..5564f7b3cd 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/flags_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/flags_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!freebsd freebsd,!cgo +// +build !linux,!freebsd freebsd,!cgo solaris,!cgo package mount diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount.go index ed7216e5c0..66ac4bf472 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount.go @@ -9,8 +9,8 @@ func GetMounts() ([]*Info, error) { return parseMountTable() } -// Mounted looks at /proc/self/mountinfo to determine of the specified -// mountpoint has been mounted +// Mounted determines if a specified mountpoint has been mounted. +// On Linux it looks at /proc/self/mountinfo and on Solaris at mnttab. func Mounted(mountpoint string) (bool, error) { entries, err := parseMountTable() if err != nil { diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_solaris.go new file mode 100644 index 0000000000..c684aa81fc --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_solaris.go @@ -0,0 +1,33 @@ +// +build solaris,cgo + +package mount + +import ( + "golang.org/x/sys/unix" + "unsafe" +) + +// #include +// #include +// #include +// int Mount(const char *spec, const char *dir, int mflag, +// char *fstype, char *dataptr, int datalen, char *optptr, int optlen) { +// return mount(spec, dir, mflag, fstype, dataptr, datalen, optptr, optlen); +// } +import "C" + +func mount(device, target, mType string, flag uintptr, data string) error { + spec := C.CString(device) + dir := C.CString(target) + fstype := C.CString(mType) + _, err := C.Mount(spec, dir, C.int(flag), fstype, nil, 0, nil, 0) + C.free(unsafe.Pointer(spec)) + C.free(unsafe.Pointer(dir)) + C.free(unsafe.Pointer(fstype)) + return err +} + +func unmount(target string, flag int) error { + err := unix.Unmount(target, flag) + return err +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_unsupported.go index eb93365eb7..a2a3bb457f 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mounter_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!freebsd freebsd,!cgo +// +build !linux,!freebsd,!solaris freebsd,!cgo solaris,!cgo package mount diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_solaris.go new file mode 100644 index 0000000000..ad9ab57f8b --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_solaris.go @@ -0,0 +1,37 @@ +// +build solaris,cgo + +package mount + +/* +#include +#include +*/ +import "C" + +import ( + "fmt" +) + +func parseMountTable() ([]*Info, error) { + mnttab := C.fopen(C.CString(C.MNTTAB), C.CString("r")) + if mnttab == nil { + return nil, fmt.Errorf("Failed to open %s", C.MNTTAB) + } + + var out []*Info + var mp C.struct_mnttab + + ret := C.getmntent(mnttab, &mp) + for ret == 0 { + var mountinfo Info + mountinfo.Mountpoint = C.GoString(mp.mnt_mountp) + mountinfo.Source = C.GoString(mp.mnt_special) + mountinfo.Fstype = C.GoString(mp.mnt_fstype) + mountinfo.Opts = C.GoString(mp.mnt_mntopts) + out = append(out, &mountinfo) + ret = C.getmntent(mnttab, &mp) + } + + C.fclose(mnttab) + return out, nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go index b8d9aa5c73..7fbcf19214 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_unsupported.go @@ -1,4 +1,4 @@ -// +build !windows,!linux,!freebsd freebsd,!cgo +// +build !windows,!linux,!freebsd,!solaris freebsd,!cgo solaris,!cgo package mount diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_solaris.go new file mode 100644 index 0000000000..49370bd3dd --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_solaris.go @@ -0,0 +1,14 @@ +package kernel + +import ( + "golang.org/x/sys/unix" +) + +func uname() (*unix.Utsname, error) { + uts := &unix.Utsname{} + + if err := unix.Uname(uts); err != nil { + return nil, err + } + return uts, nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go index 79c66b3228..1da3f239fa 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux +// +build !linux,!solaris package kernel diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_freebsd.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unix.go similarity index 94% rename from libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_freebsd.go rename to libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unix.go index c7f797a5fa..b70edcb316 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_freebsd.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unix.go @@ -1,4 +1,4 @@ -// +build freebsd +// +build freebsd solaris package reexec diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unsupported.go index ad4ea38ebb..9aed004e86 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/reexec/command_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows,!freebsd +// +build !linux,!windows,!freebsd,!solaris package reexec diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_solaris.go new file mode 100644 index 0000000000..89576b9e3b --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_solaris.go @@ -0,0 +1,42 @@ +package signal + +import ( + "syscall" +) + +// SignalMap is a map of Solaris signals. +// SIGINFO and SIGTHR not defined for Solaris +var SignalMap = map[string]syscall.Signal{ + "ABRT": syscall.SIGABRT, + "ALRM": syscall.SIGALRM, + "BUF": syscall.SIGBUS, + "CHLD": syscall.SIGCHLD, + "CONT": syscall.SIGCONT, + "EMT": syscall.SIGEMT, + "FPE": syscall.SIGFPE, + "HUP": syscall.SIGHUP, + "ILL": syscall.SIGILL, + "INT": syscall.SIGINT, + "IO": syscall.SIGIO, + "IOT": syscall.SIGIOT, + "KILL": syscall.SIGKILL, + "LWP": syscall.SIGLWP, + "PIPE": syscall.SIGPIPE, + "PROF": syscall.SIGPROF, + "QUIT": syscall.SIGQUIT, + "SEGV": syscall.SIGSEGV, + "STOP": syscall.SIGSTOP, + "SYS": syscall.SIGSYS, + "TERM": syscall.SIGTERM, + "TRAP": syscall.SIGTRAP, + "TSTP": syscall.SIGTSTP, + "TTIN": syscall.SIGTTIN, + "TTOU": syscall.SIGTTOU, + "URG": syscall.SIGURG, + "USR1": syscall.SIGUSR1, + "USR2": syscall.SIGUSR2, + "VTALRM": syscall.SIGVTALRM, + "WINCH": syscall.SIGWINCH, + "XCPU": syscall.SIGXCPU, + "XFSZ": syscall.SIGXFSZ, +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_unsupported.go index 161ba27397..c592d37dfe 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/signal/signal_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!darwin,!freebsd,!windows +// +build !linux,!darwin,!freebsd,!windows,!solaris package signal diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_solaris.go new file mode 100644 index 0000000000..313c601b12 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_solaris.go @@ -0,0 +1,128 @@ +// +build solaris,cgo + +package system + +import ( + "fmt" + "unsafe" +) + +// #cgo LDFLAGS: -lkstat +// #include +// #include +// #include +// #include +// #include +// #include +// struct swaptable *allocSwaptable(int num) { +// struct swaptable *st; +// struct swapent *swapent; +// st = (struct swaptable *)malloc(num * sizeof(swapent_t) + sizeof (int)); +// swapent = st->swt_ent; +// for (int i = 0; i < num; i++,swapent++) { +// swapent->ste_path = (char *)malloc(MAXPATHLEN * sizeof (char)); +// } +// st->swt_n = num; +// return st; +//} +// void freeSwaptable (struct swaptable *st) { +// struct swapent *swapent = st->swt_ent; +// for (int i = 0; i < st->swt_n; i++,swapent++) { +// free(swapent->ste_path); +// } +// free(st); +// } +// swapent_t getSwapEnt(swapent_t *ent, int i) { +// return ent[i]; +// } +// int64_t getPpKernel() { +// int64_t pp_kernel = 0; +// kstat_ctl_t *ksc; +// kstat_t *ks; +// kstat_named_t *knp; +// kid_t kid; +// +// if ((ksc = kstat_open()) == NULL) { +// return -1; +// } +// if ((ks = kstat_lookup(ksc, "unix", 0, "system_pages")) == NULL) { +// return -1; +// } +// if (((kid = kstat_read(ksc, ks, NULL)) == -1) || +// ((knp = kstat_data_lookup(ks, "pp_kernel")) == NULL)) { +// return -1; +// } +// switch (knp->data_type) { +// case KSTAT_DATA_UINT64: +// pp_kernel = knp->value.ui64; +// break; +// case KSTAT_DATA_UINT32: +// pp_kernel = knp->value.ui32; +// break; +// } +// pp_kernel *= sysconf(_SC_PAGESIZE); +// return (pp_kernel > 0 ? pp_kernel : -1); +// } +import "C" + +// Get the system memory info using sysconf same as prtconf +func getTotalMem() int64 { + pagesize := C.sysconf(C._SC_PAGESIZE) + npages := C.sysconf(C._SC_PHYS_PAGES) + return int64(pagesize * npages) +} + +func getFreeMem() int64 { + pagesize := C.sysconf(C._SC_PAGESIZE) + npages := C.sysconf(C._SC_AVPHYS_PAGES) + return int64(pagesize * npages) +} + +// ReadMemInfo retrieves memory statistics of the host system and returns a +// MemInfo type. +func ReadMemInfo() (*MemInfo, error) { + + ppKernel := C.getPpKernel() + MemTotal := getTotalMem() + MemFree := getFreeMem() + SwapTotal, SwapFree, err := getSysSwap() + + if ppKernel < 0 || MemTotal < 0 || MemFree < 0 || SwapTotal < 0 || + SwapFree < 0 { + return nil, fmt.Errorf("Error getting system memory info %v\n", err) + } + + meminfo := &MemInfo{} + // Total memory is total physical memory less than memory locked by kernel + meminfo.MemTotal = MemTotal - int64(ppKernel) + meminfo.MemFree = MemFree + meminfo.SwapTotal = SwapTotal + meminfo.SwapFree = SwapFree + + return meminfo, nil +} + +func getSysSwap() (int64, int64, error) { + var tSwap int64 + var fSwap int64 + var diskblksPerPage int64 + num, err := C.swapctl(C.SC_GETNSWP, nil) + if err != nil { + return -1, -1, err + } + st := C.allocSwaptable(num) + _, err = C.swapctl(C.SC_LIST, unsafe.Pointer(st)) + if err != nil { + C.freeSwaptable(st) + return -1, -1, err + } + + diskblksPerPage = int64(C.sysconf(C._SC_PAGESIZE) >> C.DEV_BSHIFT) + for i := 0; i < int(num); i++ { + swapent := C.getSwapEnt(&st.swt_ent[0], C.int(i)) + tSwap += int64(swapent.ste_pages) * diskblksPerPage + fSwap += int64(swapent.ste_free) * diskblksPerPage + } + C.freeSwaptable(st) + return tSwap, fSwap, nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_unsupported.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_unsupported.go index 82ddd30c1b..3ce019dffd 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_unsupported.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/meminfo_unsupported.go @@ -1,4 +1,4 @@ -// +build !linux,!windows +// +build !linux,!windows,!solaris package system diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_unix.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_unix.go index 1b6cc9cbd9..c607c4db09 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_unix.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_unix.go @@ -6,3 +6,9 @@ package system // executables. Each directory is separated from the next by a colon // ':' character . const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + +// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter, +// is the system drive. This is a no-op on Linux. +func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) { + return path, nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_windows.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_windows.go index 09e7f89fed..cbfe2c1576 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_windows.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/path_windows.go @@ -2,6 +2,36 @@ package system +import ( + "fmt" + "path/filepath" + "strings" +) + // DefaultPathEnv is deliberately empty on Windows as the default path will be set by // the container. Docker has no context of what the default path should be. const DefaultPathEnv = "" + +// CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path. +// This is used, for example, when validating a user provided path in docker cp. +// If a drive letter is supplied, it must be the system drive. The drive letter +// is always removed. Also, it translates it to OS semantics (IOW / to \). We +// need the path in this syntax so that it can ultimately be contatenated with +// a Windows long-path which doesn't support drive-letters. Examples: +// C: --> Fail +// C:\ --> \ +// a --> a +// /a --> \a +// d:\ --> Fail +func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) { + if len(path) == 2 && string(path[1]) == ":" { + return "", fmt.Errorf("No relative path specified in %q", path) + } + if !filepath.IsAbs(path) || len(path) < 2 { + return filepath.FromSlash(path), nil + } + if string(path[1]) == ":" && !strings.EqualFold(string(path[0]), "c") { + return "", fmt.Errorf("The specified path is not on the system drive (C:)") + } + return filepath.FromSlash(path[2:]), nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/stat_solaris.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/stat_solaris.go index b01d08acfe..0216985a25 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/stat_solaris.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/stat_solaris.go @@ -15,3 +15,20 @@ func fromStatT(s *syscall.Stat_t) (*StatT, error) { rdev: uint64(s.Rdev), mtim: s.Mtim}, nil } + +// FromStatT loads a system.StatT from a syscal.Stat_t. +func FromStatT(s *syscall.Stat_t) (*StatT, error) { + return fromStatT(s) +} + +// Stat takes a path to a file and returns +// a system.StatT type pertaining to that file. +// +// Throws an error if the file does not exist +func Stat(path string) (*StatT, error) { + s := &syscall.Stat_t{} + if err := syscall.Stat(path, s); err != nil { + return nil, err + } + return fromStatT(s) +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/syscall_windows.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/syscall_windows.go index ef596f343f..f5f2d56941 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/syscall_windows.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/system/syscall_windows.go @@ -3,10 +3,13 @@ package system import ( "syscall" "unsafe" + + "github.com/Sirupsen/logrus" ) var ( - ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") + ntuserApiset = syscall.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") + procGetVersionExW = modkernel32.NewProc("GetVersionExW") ) // OSVersion is a wrapper for Windows version information @@ -18,6 +21,21 @@ type OSVersion struct { Build uint16 } +// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx +type osVersionInfoEx struct { + OSVersionInfoSize uint32 + MajorVersion uint32 + MinorVersion uint32 + BuildNumber uint32 + PlatformID uint32 + CSDVersion [128]uint16 + ServicePackMajor uint16 + ServicePackMinor uint16 + SuiteMask uint16 + ProductType byte + Reserve byte +} + // GetOSVersion gets the operating system version on Windows. Note that // docker.exe must be manifested to get the correct version information. func GetOSVersion() OSVersion { @@ -34,6 +52,18 @@ func GetOSVersion() OSVersion { return osv } +// IsWindowsClient returns true if the SKU is client +func IsWindowsClient() bool { + osviex := &osVersionInfoEx{OSVersionInfoSize: 284} + r1, _, err := procGetVersionExW.Call(uintptr(unsafe.Pointer(osviex))) + if r1 == 0 { + logrus.Warnf("GetVersionExW failed - assuming server SKU: %v", err) + return false + } + const verNTWorkstation = 0x00000001 + return osviex.ProductType == verNTWorkstation +} + // Unmount is a platform-specific helper function to call // the unmount syscall. Not supported on Windows func Unmount(dest string) error { diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/term_windows.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/term_windows.go index cd21b5fc2b..9bc52a8c65 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/term_windows.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/term_windows.go @@ -83,11 +83,13 @@ func useNativeConsole() bool { return false } - // TODO Windows. The native emulator still has issues which - // mean it shouldn't be enabled for everyone. Change this next line to true - // to change the default to "enable if available". In the meantime, users - // can still try it out by using USE_NATIVE_CONSOLE env variable. - return false + // Must have a post-TP5 RS1 build of Windows Server 2016/Windows 10 for + // the native console to be usable. + if osv.Build < 14350 { + return false + } + + return true } // getNativeConsole returns the console modes ('state') for the native Windows console diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/windows/ansi_reader.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/windows/ansi_reader.go index 3bf2b2b6b4..5b91b78342 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/windows/ansi_reader.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/term/windows/ansi_reader.go @@ -136,14 +136,14 @@ func readInputEvents(fd uintptr, maxBytes int) ([]winterm.INPUT_RECORD, error) { // KeyEvent Translation Helpers -var arrowKeyMapPrefix = map[winterm.WORD]string{ +var arrowKeyMapPrefix = map[uint16]string{ winterm.VK_UP: "%s%sA", winterm.VK_DOWN: "%s%sB", winterm.VK_RIGHT: "%s%sC", winterm.VK_LEFT: "%s%sD", } -var keyMapPrefix = map[winterm.WORD]string{ +var keyMapPrefix = map[uint16]string{ winterm.VK_UP: "\x1B[%sA", winterm.VK_DOWN: "\x1B[%sB", winterm.VK_RIGHT: "\x1B[%sC", @@ -207,7 +207,7 @@ func keyToString(keyEvent *winterm.KEY_EVENT_RECORD, escapeSequence []byte) stri } // formatVirtualKey converts a virtual key (e.g., up arrow) into the appropriate ANSI string. -func formatVirtualKey(key winterm.WORD, controlState winterm.DWORD, escapeSequence []byte) string { +func formatVirtualKey(key uint16, controlState uint32, escapeSequence []byte) string { shift, alt, control := getControlKeys(controlState) modifier := getControlKeysModifier(shift, alt, control) @@ -223,7 +223,7 @@ func formatVirtualKey(key winterm.WORD, controlState winterm.DWORD, escapeSequen } // getControlKeys extracts the shift, alt, and ctrl key states. -func getControlKeys(controlState winterm.DWORD) (shift, alt, control bool) { +func getControlKeys(controlState uint32) (shift, alt, control bool) { shift = 0 != (controlState & winterm.SHIFT_PRESSED) alt = 0 != (controlState & (winterm.LEFT_ALT_PRESSED | winterm.RIGHT_ALT_PRESSED)) control = 0 != (controlState & (winterm.LEFT_CTRL_PRESSED | winterm.RIGHT_CTRL_PRESSED)) diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/filters/parse.go b/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/filters/parse.go deleted file mode 100644 index dc2c48b894..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/filters/parse.go +++ /dev/null @@ -1,307 +0,0 @@ -// Package filters provides helper function to parse and handle command line -// filter, used for example in docker ps or docker images commands. -package filters - -import ( - "encoding/json" - "errors" - "fmt" - "regexp" - "strings" - - "github.com/docker/engine-api/types/versions" -) - -// Args stores filter arguments as map key:{map key: bool}. -// It contains an aggregation of the map of arguments (which are in the form -// of -f 'key=value') based on the key, and stores values for the same key -// in a map with string keys and boolean values. -// e.g given -f 'label=label1=1' -f 'label=label2=2' -f 'image.name=ubuntu' -// the args will be {"image.name":{"ubuntu":true},"label":{"label1=1":true,"label2=2":true}} -type Args struct { - fields map[string]map[string]bool -} - -// NewArgs initializes a new Args struct. -func NewArgs() Args { - return Args{fields: map[string]map[string]bool{}} -} - -// ParseFlag parses the argument to the filter flag. Like -// -// `docker ps -f 'created=today' -f 'image.name=ubuntu*'` -// -// If prev map is provided, then it is appended to, and returned. By default a new -// map is created. -func ParseFlag(arg string, prev Args) (Args, error) { - filters := prev - if len(arg) == 0 { - return filters, nil - } - - if !strings.Contains(arg, "=") { - return filters, ErrBadFormat - } - - f := strings.SplitN(arg, "=", 2) - - name := strings.ToLower(strings.TrimSpace(f[0])) - value := strings.TrimSpace(f[1]) - - filters.Add(name, value) - - return filters, nil -} - -// ErrBadFormat is an error returned in case of bad format for a filter. -var ErrBadFormat = errors.New("bad format of filter (expected name=value)") - -// ToParam packs the Args into a string for easy transport from client to server. -func ToParam(a Args) (string, error) { - // this way we don't URL encode {}, just empty space - if a.Len() == 0 { - return "", nil - } - - buf, err := json.Marshal(a.fields) - if err != nil { - return "", err - } - return string(buf), nil -} - -// ToParamWithVersion packs the Args into a string for easy transport from client to server. -// The generated string will depend on the specified version (corresponding to the API version). -func ToParamWithVersion(version string, a Args) (string, error) { - // this way we don't URL encode {}, just empty space - if a.Len() == 0 { - return "", nil - } - - // for daemons older than v1.10, filter must be of the form map[string][]string - buf := []byte{} - err := errors.New("") - if version != "" && versions.LessThan(version, "1.22") { - buf, err = json.Marshal(convertArgsToSlice(a.fields)) - } else { - buf, err = json.Marshal(a.fields) - } - if err != nil { - return "", err - } - return string(buf), nil -} - -// FromParam unpacks the filter Args. -func FromParam(p string) (Args, error) { - if len(p) == 0 { - return NewArgs(), nil - } - - r := strings.NewReader(p) - d := json.NewDecoder(r) - - m := map[string]map[string]bool{} - if err := d.Decode(&m); err != nil { - r.Seek(0, 0) - - // Allow parsing old arguments in slice format. - // Because other libraries might be sending them in this format. - deprecated := map[string][]string{} - if deprecatedErr := d.Decode(&deprecated); deprecatedErr == nil { - m = deprecatedArgs(deprecated) - } else { - return NewArgs(), err - } - } - return Args{m}, nil -} - -// Get returns the list of values associates with a field. -// It returns a slice of strings to keep backwards compatibility with old code. -func (filters Args) Get(field string) []string { - values := filters.fields[field] - if values == nil { - return make([]string, 0) - } - slice := make([]string, 0, len(values)) - for key := range values { - slice = append(slice, key) - } - return slice -} - -// Add adds a new value to a filter field. -func (filters Args) Add(name, value string) { - if _, ok := filters.fields[name]; ok { - filters.fields[name][value] = true - } else { - filters.fields[name] = map[string]bool{value: true} - } -} - -// Del removes a value from a filter field. -func (filters Args) Del(name, value string) { - if _, ok := filters.fields[name]; ok { - delete(filters.fields[name], value) - } -} - -// Len returns the number of fields in the arguments. -func (filters Args) Len() int { - return len(filters.fields) -} - -// MatchKVList returns true if the values for the specified field matches the ones -// from the sources. -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'label' and sources are {'label1': '1', 'label2': '2'} -// it returns true. -func (filters Args) MatchKVList(field string, sources map[string]string) bool { - fieldValues := filters.fields[field] - - //do not filter if there is no filter set or cannot determine filter - if len(fieldValues) == 0 { - return true - } - - if sources == nil || len(sources) == 0 { - return false - } - - for name2match := range fieldValues { - testKV := strings.SplitN(name2match, "=", 2) - - v, ok := sources[testKV[0]] - if !ok { - return false - } - if len(testKV) == 2 && testKV[1] != v { - return false - } - } - - return true -} - -// Match returns true if the values for the specified field matches the source string -// e.g. given Args are {'label': {'label1=1','label2=1'}, 'image.name', {'ubuntu'}}, -// field is 'image.name' and source is 'ubuntu' -// it returns true. -func (filters Args) Match(field, source string) bool { - if filters.ExactMatch(field, source) { - return true - } - - fieldValues := filters.fields[field] - for name2match := range fieldValues { - match, err := regexp.MatchString(name2match, source) - if err != nil { - continue - } - if match { - return true - } - } - return false -} - -// ExactMatch returns true if the source matches exactly one of the filters. -func (filters Args) ExactMatch(field, source string) bool { - fieldValues, ok := filters.fields[field] - //do not filter if there is no filter set or cannot determine filter - if !ok || len(fieldValues) == 0 { - return true - } - - // try to match full name value to avoid O(N) regular expression matching - return fieldValues[source] -} - -// UniqueExactMatch returns true if there is only one filter and the source matches exactly this one. -func (filters Args) UniqueExactMatch(field, source string) bool { - fieldValues := filters.fields[field] - //do not filter if there is no filter set or cannot determine filter - if len(fieldValues) == 0 { - return true - } - if len(filters.fields[field]) != 1 { - return false - } - - // try to match full name value to avoid O(N) regular expression matching - return fieldValues[source] -} - -// FuzzyMatch returns true if the source matches exactly one of the filters, -// or the source has one of the filters as a prefix. -func (filters Args) FuzzyMatch(field, source string) bool { - if filters.ExactMatch(field, source) { - return true - } - - fieldValues := filters.fields[field] - for prefix := range fieldValues { - if strings.HasPrefix(source, prefix) { - return true - } - } - return false -} - -// Include returns true if the name of the field to filter is in the filters. -func (filters Args) Include(field string) bool { - _, ok := filters.fields[field] - return ok -} - -// Validate ensures that all the fields in the filter are valid. -// It returns an error as soon as it finds an invalid field. -func (filters Args) Validate(accepted map[string]bool) error { - for name := range filters.fields { - if !accepted[name] { - return fmt.Errorf("Invalid filter '%s'", name) - } - } - return nil -} - -// WalkValues iterates over the list of filtered values for a field. -// It stops the iteration if it finds an error and it returns that error. -func (filters Args) WalkValues(field string, op func(value string) error) error { - if _, ok := filters.fields[field]; !ok { - return nil - } - for v := range filters.fields[field] { - if err := op(v); err != nil { - return err - } - } - return nil -} - -func deprecatedArgs(d map[string][]string) map[string]map[string]bool { - m := map[string]map[string]bool{} - for k, v := range d { - values := map[string]bool{} - for _, vv := range v { - values[vv] = true - } - m[k] = values - } - return m -} - -func convertArgsToSlice(f map[string]map[string]bool) map[string][]string { - m := map[string][]string{} - for k, v := range f { - values := []string{} - for kk := range v { - if v[kk] { - values = append(values, kk) - } - } - m[k] = values - } - return m -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/README.md b/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/README.md deleted file mode 100644 index cdac50a53c..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/README.md +++ /dev/null @@ -1,14 +0,0 @@ -## Legacy API type versions - -This package includes types for legacy API versions. The stable version of the API types live in `api/types/*.go`. - -Consider moving a type here when you need to keep backwards compatibility in the API. This legacy types are organized by the latest API version they appear in. For instance, types in the `v1p19` package are valid for API versions below or equal `1.19`. Types in the `v1p20` package are valid for the API version `1.20`, since the versions below that will use the legacy types in `v1p19`. - -### Package name conventions - -The package name convention is to use `v` as a prefix for the version number and `p`(patch) as a separator. We use this nomenclature due to a few restrictions in the Go package name convention: - -1. We cannot use `.` because it's interpreted by the language, think of `v1.20.CallFunction`. -2. We cannot use `_` because golint complains about it. The code is actually valid, but it looks probably more weird: `v1_20.CallFunction`. - -For instance, if you want to modify a type that was available in the version `1.21` of the API but it will have different fields in the version `1.22`, you want to create a new package under `api/types/versions/v1p21`. diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/compare.go b/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/compare.go deleted file mode 100644 index 611d4fed66..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/engine-api/types/versions/compare.go +++ /dev/null @@ -1,62 +0,0 @@ -package versions - -import ( - "strconv" - "strings" -) - -// compare compares two version strings -// returns -1 if v1 < v2, 1 if v1 > v2, 0 otherwise. -func compare(v1, v2 string) int { - var ( - currTab = strings.Split(v1, ".") - otherTab = strings.Split(v2, ".") - ) - - max := len(currTab) - if len(otherTab) > max { - max = len(otherTab) - } - for i := 0; i < max; i++ { - var currInt, otherInt int - - if len(currTab) > i { - currInt, _ = strconv.Atoi(currTab[i]) - } - if len(otherTab) > i { - otherInt, _ = strconv.Atoi(otherTab[i]) - } - if currInt > otherInt { - return 1 - } - if otherInt > currInt { - return -1 - } - } - return 0 -} - -// LessThan checks if a version is less than another -func LessThan(v, other string) bool { - return compare(v, other) == -1 -} - -// LessThanOrEqualTo checks if a version is less than or equal to another -func LessThanOrEqualTo(v, other string) bool { - return compare(v, other) <= 0 -} - -// GreaterThan checks if a version is greater than another -func GreaterThan(v, other string) bool { - return compare(v, other) == 1 -} - -// GreaterThanOrEqualTo checks if a version is greater than or equal to another -func GreaterThanOrEqualTo(v, other string) bool { - return compare(v, other) >= 0 -} - -// Equal checks if a version is equal to another -func Equal(v, other string) bool { - return compare(v, other) == 0 -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/hashicorp/go-msgpack/codec/msgpack_test.py b/libnetwork/Godeps/_workspace/src/github.com/hashicorp/go-msgpack/codec/msgpack_test.py old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/.travis.yml b/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/.travis.yml deleted file mode 100644 index 16d1430aa2..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go -go: - - tip -before_install: - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover -script: - - $HOME/gopath/bin/goveralls -repotoken 2FMhp57u8LcstKL9B190fLTcEnBtAAiEL diff --git a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/README.md b/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/README.md deleted file mode 100644 index 56f357fad7..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/README.md +++ /dev/null @@ -1,47 +0,0 @@ -# go-shellwords - -[![Coverage Status](https://coveralls.io/repos/mattn/go-shellwords/badge.png?branch=master)](https://coveralls.io/r/mattn/go-shellwords?branch=master) -[![Build Status](https://travis-ci.org/mattn/go-shellwords.svg?branch=master)](https://travis-ci.org/mattn/go-shellwords) - -Parse line as shell words. - -## Usage - -```go -args, err := shellwords.Parse("./foo --bar=baz") -// args should be ["./foo", "--bar=baz"] -``` - -```go -os.Setenv("FOO", "bar") -p := shellwords.NewParser() -p.ParseEnv = true -args, err := p.Parse("./foo $FOO") -// args should be ["./foo", "bar"] -``` - -```go -p := shellwords.NewParser() -p.ParseBacktick = true -args, err := p.Parse("./foo `echo $SHELL`") -// args should be ["./foo", "/bin/bash"] -``` - -```go -shellwords.ParseBacktick = true -p := shellwords.NewParser() -args, err := p.Parse("./foo `echo $SHELL`") -// args should be ["./foo", "/bin/bash"] -``` - -# Thanks - -This is based on cpan module [Parse::CommandLine](https://metacpan.org/pod/Parse::CommandLine). - -# License - -under the MIT License: http://mattn.mit-license.org/2014 - -# Author - -Yasuhiro Matsumoto (a.k.a mattn) diff --git a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/shellwords.go b/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/shellwords.go deleted file mode 100644 index 1abaa6c9df..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/shellwords.go +++ /dev/null @@ -1,134 +0,0 @@ -package shellwords - -import ( - "errors" - "os" - "regexp" - "strings" -) - -var ( - ParseEnv bool = false - ParseBacktick bool = false -) - -var envRe = regexp.MustCompile(`\$({[a-zA-Z0-9_]+}|[a-zA-Z0-9_]+)`) - -func isSpace(r rune) bool { - switch r { - case ' ', '\t', '\r', '\n': - return true - } - return false -} - -func replaceEnv(s string) string { - return envRe.ReplaceAllStringFunc(s, func(s string) string { - s = s[1:] - if s[0] == '{' { - s = s[1 : len(s)-1] - } - return os.Getenv(s) - }) -} - -type Parser struct { - ParseEnv bool - ParseBacktick bool -} - -func NewParser() *Parser { - return &Parser{ParseEnv, ParseBacktick} -} - -func (p *Parser) Parse(line string) ([]string, error) { - line = strings.TrimSpace(line) - - args := []string{} - buf := "" - var escaped, doubleQuoted, singleQuoted, backQuote bool - backtick := "" - - for _, r := range line { - if escaped { - buf += string(r) - escaped = false - continue - } - - if r == '\\' { - if singleQuoted { - buf += string(r) - } else { - escaped = true - } - continue - } - - if isSpace(r) { - if singleQuoted || doubleQuoted || backQuote { - buf += string(r) - backtick += string(r) - } else if buf != "" { - if p.ParseEnv { - buf = replaceEnv(buf) - } - args = append(args, buf) - buf = "" - } - continue - } - - switch r { - case '`': - if !singleQuoted && !doubleQuoted { - if p.ParseBacktick { - if backQuote { - out, err := shellRun(backtick) - if err != nil { - return nil, err - } - buf = out - } - backtick = "" - backQuote = !backQuote - continue - } - backtick = "" - backQuote = !backQuote - } - case '"': - if !singleQuoted { - doubleQuoted = !doubleQuoted - continue - } - case '\'': - if !doubleQuoted { - singleQuoted = !singleQuoted - continue - } - } - - buf += string(r) - if backQuote { - backtick += string(r) - } - } - - if buf != "" { - if p.ParseEnv { - buf = replaceEnv(buf) - } - args = append(args, buf) - } - - if escaped || singleQuoted || doubleQuoted || backQuote { - return nil, errors.New("invalid command line string") - } - - return args, nil -} - -func Parse(line string) ([]string, error) { - return NewParser().Parse(line) -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_posix.go b/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_posix.go deleted file mode 100644 index 4f8ac55e47..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_posix.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !windows - -package shellwords - -import ( - "errors" - "os" - "os/exec" - "strings" -) - -func shellRun(line string) (string, error) { - shell := os.Getenv("SHELL") - b, err := exec.Command(shell, "-c", line).Output() - if err != nil { - return "", errors.New(err.Error() + ":" + string(b)) - } - return strings.TrimSpace(string(b)), nil -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_windows.go b/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_windows.go deleted file mode 100644 index 7cad4cf06f..0000000000 --- a/libnetwork/Godeps/_workspace/src/github.com/mattn/go-shellwords/util_windows.go +++ /dev/null @@ -1,17 +0,0 @@ -package shellwords - -import ( - "errors" - "os" - "os/exec" - "strings" -) - -func shellRun(line string) (string, error) { - shell := os.Getenv("COMSPEC") - b, err := exec.Command(shell, "/c", line).Output() - if err != nil { - return "", errors.New(err.Error() + ":" + string(b)) - } - return strings.TrimSpace(string(b)), nil -} diff --git a/libnetwork/Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh b/libnetwork/Godeps/_workspace/src/github.com/ugorji/go/codec/prebuild.sh old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/github.com/ugorji/go/codec/test.py b/libnetwork/Godeps/_workspace/src/github.com/ugorji/go/codec/test.py old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mkall.sh old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mkerrors.sh old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksyscall_solaris.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysctl_openbsd.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysctl_openbsd.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_darwin.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_darwin.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_dragonfly.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_freebsd.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_freebsd.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_linux.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_linux.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_netbsd.pl old mode 100644 new mode 100755 diff --git a/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_openbsd.pl b/libnetwork/Godeps/_workspace/src/golang.org/x/sys/unix/mksysnum_openbsd.pl old mode 100644 new mode 100755