From 4399989c53d1c3e6a6028a08eecc4f5735fd93b8 Mon Sep 17 00:00:00 2001 From: Jana Radhakrishnan Date: Mon, 4 May 2015 04:09:50 +0000 Subject: [PATCH] Updated Godeps to the latest versions of docker packages. Signed-off-by: Jana Radhakrishnan --- libnetwork/Godeps/Godeps.json | 37 +- .../docker/docker/pkg/etchosts/etchosts.go | 16 +- .../docker/docker/pkg/iptables/firewalld.go | 164 ++++ .../docker/pkg/iptables/firewalld_test.go | 78 ++ .../docker/docker/pkg/iptables/iptables.go | 21 +- .../docker/docker/pkg/mflag/flag.go | 3 +- .../docker/pkg/parsers/kernel/kernel.go | 93 ++ .../docker/pkg/parsers/kernel/kernel_test.go | 61 ++ .../docker/pkg/parsers/kernel/uname_linux.go | 16 + .../pkg/parsers/kernel/uname_unsupported.go | 15 + .../github.com/godbus/dbus/CONTRIBUTING.md | 50 ++ .../src/github.com/godbus/dbus/LICENSE | 25 + .../src/github.com/godbus/dbus/MAINTAINERS | 2 + .../github.com/godbus/dbus/README.markdown | 38 + .../src/github.com/godbus/dbus/auth.go | 253 ++++++ .../github.com/godbus/dbus/auth_external.go | 26 + .../src/github.com/godbus/dbus/auth_sha1.go | 102 +++ .../src/github.com/godbus/dbus/call.go | 147 ++++ .../src/github.com/godbus/dbus/conn.go | 609 +++++++++++++ .../src/github.com/godbus/dbus/conn_darwin.go | 21 + .../src/github.com/godbus/dbus/conn_other.go | 27 + .../src/github.com/godbus/dbus/conn_test.go | 199 +++++ .../src/github.com/godbus/dbus/dbus.go | 258 ++++++ .../src/github.com/godbus/dbus/decoder.go | 228 +++++ .../src/github.com/godbus/dbus/doc.go | 63 ++ .../src/github.com/godbus/dbus/encoder.go | 208 +++++ .../github.com/godbus/dbus/encoder_test.go | 58 ++ .../github.com/godbus/dbus/examples_test.go | 50 ++ .../src/github.com/godbus/dbus/export.go | 302 +++++++ .../src/github.com/godbus/dbus/homedir.go | 28 + .../github.com/godbus/dbus/homedir_dynamic.go | 15 + .../github.com/godbus/dbus/homedir_static.go | 45 + .../github.com/godbus/dbus/introspect/call.go | 27 + .../godbus/dbus/introspect/introspect.go | 86 ++ .../godbus/dbus/introspect/introspectable.go | 75 ++ .../src/github.com/godbus/dbus/message.go | 346 ++++++++ .../src/github.com/godbus/dbus/prop/prop.go | 264 ++++++ .../src/github.com/godbus/dbus/proto_test.go | 369 ++++++++ .../src/github.com/godbus/dbus/sig.go | 257 ++++++ .../src/github.com/godbus/dbus/sig_test.go | 70 ++ .../godbus/dbus/transport_darwin.go | 6 + .../godbus/dbus/transport_generic.go | 35 + .../github.com/godbus/dbus/transport_unix.go | 196 +++++ .../godbus/dbus/transport_unix_test.go | 49 ++ .../dbus/transport_unixcred_dragonfly.go | 95 ++ .../godbus/dbus/transport_unixcred_linux.go | 25 + .../src/github.com/godbus/dbus/variant.go | 139 +++ .../github.com/godbus/dbus/variant_lexer.go | 284 ++++++ .../github.com/godbus/dbus/variant_parser.go | 817 ++++++++++++++++++ .../github.com/godbus/dbus/variant_test.go | 78 ++ 50 files changed, 6449 insertions(+), 27 deletions(-) create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/LICENSE create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/MAINTAINERS create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/README.markdown create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/auth.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/auth_external.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/auth_sha1.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/call.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/conn.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/conn_darwin.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/conn_other.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/conn_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/dbus.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/decoder.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/doc.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/encoder.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/encoder_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/examples_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/export.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/homedir.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/homedir_dynamic.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/homedir_static.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/introspect/call.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/introspect/introspect.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/introspect/introspectable.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/message.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/prop/prop.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/proto_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/sig.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/sig_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_darwin.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_generic.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_unix.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_unix_test.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_unixcred_dragonfly.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/transport_unixcred_linux.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/variant.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/variant_lexer.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/variant_parser.go create mode 100644 libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/variant_test.go diff --git a/libnetwork/Godeps/Godeps.json b/libnetwork/Godeps/Godeps.json index 30c8a14de8..055f878e4c 100644 --- a/libnetwork/Godeps/Godeps.json +++ b/libnetwork/Godeps/Godeps.json @@ -12,49 +12,54 @@ }, { "ImportPath": "github.com/docker/docker/pkg/etchosts", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/homedir", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/iptables", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/mflag", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/parsers/kernel", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/proxy", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/reexec", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/docker/pkg/stringid", - "Comment": "v1.4.1-2492-ge690ad9", - "Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6" + "Comment": "v1.4.1-3152-g3e85803", + "Rev": "3e85803f311c3883a9b395ad046c894ea255e9be" }, { "ImportPath": "github.com/docker/libcontainer/user", "Comment": "v1.4.0-495-g3e66118", "Rev": "3e661186ba24f259d3860f067df052c7f6904bee" }, + { + "ImportPath": "github.com/godbus/dbus", + "Comment": "v2-3-g4160802", + "Rev": "41608027bdce7bfa8959d653a00b954591220e67" + }, { "ImportPath": "github.com/vishvananda/netlink", "Rev": "8eb64238879fed52fd51c5b30ad20b928fb4c36c" diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/etchosts/etchosts.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/etchosts/etchosts.go index d7edef27f6..bef4a480cb 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/etchosts/etchosts.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/etchosts/etchosts.go @@ -8,16 +8,19 @@ import ( "regexp" ) +// Structure for a single host record type Record struct { Hosts string IP string } +// Writes record to file and returns bytes written or error func (r Record) WriteTo(w io.Writer) (int64, error) { n, err := fmt.Fprintf(w, "%s\t%s\n", r.IP, r.Hosts) return int64(n), err } +// Default hosts config records slice var defaultContent = []Record{ {Hosts: "localhost", IP: "127.0.0.1"}, {Hosts: "localhost ip6-localhost ip6-loopback", IP: "::1"}, @@ -27,9 +30,14 @@ var defaultContent = []Record{ {Hosts: "ip6-allrouters", IP: "ff02::2"}, } +// Build function +// path is path to host file string required +// IP, hostname, and domainname set main record leave empty for no master record +// extraContent is an array of extra host records. func Build(path, IP, hostname, domainname string, extraContent []Record) error { content := bytes.NewBuffer(nil) if IP != "" { + //set main record var mainRec Record mainRec.IP = IP if domainname != "" { @@ -41,13 +49,13 @@ func Build(path, IP, hostname, domainname string, extraContent []Record) error { return err } } - + // Write defaultContent slice to buffer for _, r := range defaultContent { if _, err := r.WriteTo(content); err != nil { return err } } - + // Write extra content from function arguments for _, r := range extraContent { if _, err := r.WriteTo(content); err != nil { return err @@ -57,6 +65,10 @@ func Build(path, IP, hostname, domainname string, extraContent []Record) error { return ioutil.WriteFile(path, content.Bytes(), 0644) } +// Update all IP addresses where hostname matches. +// path is path to host file +// IP is new IP address +// hostname is hostname to search for to replace IP func Update(path, IP, hostname string) error { old, err := ioutil.ReadFile(path) if err != nil { diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld.go new file mode 100644 index 0000000000..1c0cddb0f0 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld.go @@ -0,0 +1,164 @@ +package iptables + +import ( + "fmt" + "strings" + + "github.com/Sirupsen/logrus" + "github.com/godbus/dbus" +) + +type IPV string + +const ( + Iptables IPV = "ipv4" + Ip6tables IPV = "ipv6" + Ebtables IPV = "eb" +) +const ( + dbusInterface = "org.fedoraproject.FirewallD1" + dbusPath = "/org/fedoraproject/FirewallD1" +) + +// Conn is a connection to firewalld dbus endpoint. +type Conn struct { + sysconn *dbus.Conn + sysobj *dbus.Object + signal chan *dbus.Signal +} + +var ( + connection *Conn + firewalldRunning bool // is Firewalld service running + onReloaded []*func() // callbacks when Firewalld has been reloaded +) + +func FirewalldInit() { + var err error + + connection, err = newConnection() + + if err != nil { + logrus.Errorf("Failed to connect to D-Bus system bus: %s", err) + } + if connection != nil { + go signalHandler() + } + + firewalldRunning = checkRunning() +} + +// New() establishes a connection to the system bus. +func newConnection() (*Conn, error) { + c := new(Conn) + if err := c.initConnection(); err != nil { + return nil, err + } + + return c, nil +} + +// Innitialize D-Bus connection. +func (c *Conn) initConnection() error { + var err error + + c.sysconn, err = dbus.SystemBus() + if err != nil { + return err + } + + // This never fails, even if the service is not running atm. + c.sysobj = c.sysconn.Object(dbusInterface, dbus.ObjectPath(dbusPath)) + + rule := fmt.Sprintf("type='signal',path='%s',interface='%s',sender='%s',member='Reloaded'", + dbusPath, dbusInterface, dbusInterface) + c.sysconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, rule) + + rule = fmt.Sprintf("type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',sender='org.freedesktop.DBus',arg0='%s'", + dbusInterface) + c.sysconn.BusObject().Call("org.freedesktop.DBus.AddMatch", 0, rule) + + c.signal = make(chan *dbus.Signal, 10) + c.sysconn.Signal(c.signal) + + return nil +} + +func signalHandler() { + for signal := range connection.signal { + if strings.Contains(signal.Name, "NameOwnerChanged") { + firewalldRunning = checkRunning() + dbusConnectionChanged(signal.Body) + } else if strings.Contains(signal.Name, "Reloaded") { + reloaded() + } + } +} + +func dbusConnectionChanged(args []interface{}) { + name := args[0].(string) + old_owner := args[1].(string) + new_owner := args[2].(string) + + if name != dbusInterface { + return + } + + if len(new_owner) > 0 { + connectionEstablished() + } else if len(old_owner) > 0 { + connectionLost() + } +} + +func connectionEstablished() { + reloaded() +} + +func connectionLost() { + // Doesn't do anything for now. Libvirt also doesn't react to this. +} + +// call all callbacks +func reloaded() { + for _, pf := range onReloaded { + (*pf)() + } +} + +// add callback +func OnReloaded(callback func()) { + for _, pf := range onReloaded { + if pf == &callback { + return + } + } + onReloaded = append(onReloaded, &callback) +} + +// Call some remote method to see whether the service is actually running. +func checkRunning() bool { + var zone string + var err error + + if connection != nil { + err = connection.sysobj.Call(dbusInterface+".getDefaultZone", 0).Store(&zone) + logrus.Infof("Firewalld running: %t", err == nil) + return err == nil + } + logrus.Info("Firewalld not running") + return false +} + +// Firewalld's passthrough method simply passes args through to iptables/ip6tables +func Passthrough(ipv IPV, args ...string) ([]byte, error) { + var output string + + logrus.Debugf("Firewalld passthrough: %s, %s", ipv, args) + err := connection.sysobj.Call(dbusInterface+".direct.passthrough", 0, ipv, args).Store(&output) + if output != "" { + logrus.Debugf("passthrough output: %s", output) + } + + return []byte(output), err +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld_test.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld_test.go new file mode 100644 index 0000000000..3896007d64 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/firewalld_test.go @@ -0,0 +1,78 @@ +package iptables + +import ( + "net" + "strconv" + "testing" +) + +func TestFirewalldInit(t *testing.T) { + FirewalldInit() +} + +func TestReloaded(t *testing.T) { + var err error + var fwdChain *Chain + + fwdChain, err = NewChain("FWD", "lo", Filter) + if err != nil { + t.Fatal(err) + } + defer fwdChain.Remove() + + // copy-pasted from iptables_test:TestLink + ip1 := net.ParseIP("192.168.1.1") + ip2 := net.ParseIP("192.168.1.2") + port := 1234 + proto := "tcp" + + err = fwdChain.Link(Append, ip1, ip2, port, proto) + if err != nil { + t.Fatal(err) + } else { + // to be re-called again later + OnReloaded(func() { fwdChain.Link(Append, ip1, ip2, port, proto) }) + } + + rule1 := []string{ + "-i", fwdChain.Bridge, + "-o", fwdChain.Bridge, + "-p", proto, + "-s", ip1.String(), + "-d", ip2.String(), + "--dport", strconv.Itoa(port), + "-j", "ACCEPT"} + + if !Exists(fwdChain.Table, fwdChain.Name, rule1...) { + t.Fatalf("rule1 does not exist") + } + + // flush all rules + fwdChain.Remove() + + reloaded() + + // make sure the rules have been recreated + if !Exists(fwdChain.Table, fwdChain.Name, rule1...) { + t.Fatalf("rule1 hasn't been recreated") + } +} + +func TestPassthrough(t *testing.T) { + rule1 := []string{ + "-i", "lo", + "-p", "udp", + "--dport", "123", + "-j", "ACCEPT"} + + if firewalldRunning { + _, err := Passthrough(Iptables, append([]string{"-A"}, rule1...)...) + if err != nil { + t.Fatal(err) + } + if !Exists(Filter, "INPUT", rule1...) { + t.Fatalf("rule1 does not exist") + } + } + +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/iptables.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/iptables.go index f8b3aa769d..9983ec61ff 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/iptables.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/iptables/iptables.go @@ -41,7 +41,7 @@ type ChainError struct { Output []byte } -func (e *ChainError) Error() string { +func (e ChainError) Error() string { return fmt.Sprintf("Error iptables %s: %s", e.Chain, string(e.Output)) } @@ -142,7 +142,7 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, destAddr stri "--to-destination", net.JoinHostPort(destAddr, strconv.Itoa(destPort))); err != nil { return err } else if len(output) != 0 { - return &ChainError{Chain: "FORWARD", Output: output} + return ChainError{Chain: "FORWARD", Output: output} } if output, err := Raw("-t", string(Filter), string(action), c.Name, @@ -154,7 +154,7 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, destAddr stri "-j", "ACCEPT"); err != nil { return err } else if len(output) != 0 { - return &ChainError{Chain: "FORWARD", Output: output} + return ChainError{Chain: "FORWARD", Output: output} } if output, err := Raw("-t", string(Nat), string(action), "POSTROUTING", @@ -165,7 +165,7 @@ func (c *Chain) Forward(action Action, ip net.IP, port int, proto, destAddr stri "-j", "MASQUERADE"); err != nil { return err } else if len(output) != 0 { - return &ChainError{Chain: "FORWARD", Output: output} + return ChainError{Chain: "FORWARD", Output: output} } return nil @@ -208,7 +208,7 @@ func (c *Chain) Prerouting(action Action, args ...string) error { if output, err := Raw(append(a, "-j", c.Name)...); err != nil { return err } else if len(output) != 0 { - return &ChainError{Chain: "PREROUTING", Output: output} + return ChainError{Chain: "PREROUTING", Output: output} } return nil } @@ -222,7 +222,7 @@ func (c *Chain) Output(action Action, args ...string) error { if output, err := Raw(append(a, "-j", c.Name)...); err != nil { return err } else if len(output) != 0 { - return &ChainError{Chain: "OUTPUT", Output: output} + return ChainError{Chain: "OUTPUT", Output: output} } return nil } @@ -261,7 +261,7 @@ func Exists(table Table, chain string, rule ...string) bool { // parse "iptables -S" for the rule (this checks rules in a specific chain // in a specific table) ruleString := strings.Join(rule, " ") - existingRules, _ := exec.Command("iptables", "-t", string(table), "-S", chain).Output() + existingRules, _ := exec.Command(iptablesPath, "-t", string(table), "-S", chain).Output() // regex to replace ips in rule // because MASQUERADE rule will not be exactly what was passed @@ -275,6 +275,13 @@ func Exists(table Table, chain string, rule ...string) bool { // Call 'iptables' system command, passing supplied arguments func Raw(args ...string) ([]byte, error) { + if firewalldRunning { + output, err := Passthrough(Iptables, args...) + if err == nil || !strings.Contains(err.Error(), "was not provided by any .service files") { + return output, err + } + + } if err := initCheck(); err != nil { return nil, err diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/flag.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/flag.go index f2da1cd1b9..f0d20d99b0 100644 --- a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/flag.go +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/mflag/flag.go @@ -486,8 +486,7 @@ func (f *FlagSet) Set(name, value string) error { if !ok { return fmt.Errorf("no such flag -%v", name) } - err := flag.Value.Set(value) - if err != nil { + if err := flag.Value.Set(value); err != nil { return err } if f.actual == nil { diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go new file mode 100644 index 0000000000..70d09003a3 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go @@ -0,0 +1,93 @@ +package kernel + +import ( + "bytes" + "errors" + "fmt" +) + +type KernelVersionInfo struct { + Kernel int + Major int + Minor int + Flavor string +} + +func (k *KernelVersionInfo) String() string { + return fmt.Sprintf("%d.%d.%d%s", k.Kernel, k.Major, k.Minor, k.Flavor) +} + +// Compare two KernelVersionInfo struct. +// Returns -1 if a < b, 0 if a == b, 1 it a > b +func CompareKernelVersion(a, b *KernelVersionInfo) int { + if a.Kernel < b.Kernel { + return -1 + } else if a.Kernel > b.Kernel { + return 1 + } + + if a.Major < b.Major { + return -1 + } else if a.Major > b.Major { + return 1 + } + + if a.Minor < b.Minor { + return -1 + } else if a.Minor > b.Minor { + return 1 + } + + return 0 +} + +func GetKernelVersion() (*KernelVersionInfo, error) { + var ( + err error + ) + + uts, err := uname() + if err != nil { + return nil, err + } + + release := make([]byte, len(uts.Release)) + + i := 0 + for _, c := range uts.Release { + release[i] = byte(c) + i++ + } + + // Remove the \x00 from the release for Atoi to parse correctly + release = release[:bytes.IndexByte(release, 0)] + + return ParseRelease(string(release)) +} + +func ParseRelease(release string) (*KernelVersionInfo, error) { + var ( + kernel, major, minor, parsed int + flavor, partial string + ) + + // Ignore error from Sscanf to allow an empty flavor. Instead, just + // make sure we got all the version numbers. + parsed, _ = fmt.Sscanf(release, "%d.%d%s", &kernel, &major, &partial) + if parsed < 2 { + return nil, errors.New("Can't parse kernel version " + release) + } + + // sometimes we have 3.12.25-gentoo, but sometimes we just have 3.12-1-amd64 + parsed, _ = fmt.Sscanf(partial, ".%d%s", &minor, &flavor) + if parsed < 1 { + flavor = partial + } + + return &KernelVersionInfo{ + Kernel: kernel, + Major: major, + Minor: minor, + Flavor: flavor, + }, nil +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go new file mode 100644 index 0000000000..e211a63b7d --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go @@ -0,0 +1,61 @@ +package kernel + +import ( + "testing" +) + +func assertParseRelease(t *testing.T, release string, b *KernelVersionInfo, result int) { + var ( + a *KernelVersionInfo + ) + a, _ = ParseRelease(release) + + if r := CompareKernelVersion(a, b); r != result { + t.Fatalf("Unexpected kernel version comparison result. Found %d, expected %d", r, result) + } + if a.Flavor != b.Flavor { + t.Fatalf("Unexpected parsed kernel flavor. Found %s, expected %s", a.Flavor, b.Flavor) + } +} + +func TestParseRelease(t *testing.T) { + assertParseRelease(t, "3.8.0", &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, 0) + assertParseRelease(t, "3.4.54.longterm-1", &KernelVersionInfo{Kernel: 3, Major: 4, Minor: 54, Flavor: ".longterm-1"}, 0) + assertParseRelease(t, "3.4.54.longterm-1", &KernelVersionInfo{Kernel: 3, Major: 4, Minor: 54, Flavor: ".longterm-1"}, 0) + assertParseRelease(t, "3.8.0-19-generic", &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Flavor: "-19-generic"}, 0) + assertParseRelease(t, "3.12.8tag", &KernelVersionInfo{Kernel: 3, Major: 12, Minor: 8, Flavor: "tag"}, 0) + assertParseRelease(t, "3.12-1-amd64", &KernelVersionInfo{Kernel: 3, Major: 12, Minor: 0, Flavor: "-1-amd64"}, 0) +} + +func assertKernelVersion(t *testing.T, a, b *KernelVersionInfo, result int) { + if r := CompareKernelVersion(a, b); r != result { + t.Fatalf("Unexpected kernel version comparison result. Found %d, expected %d", r, result) + } +} + +func TestCompareKernelVersion(t *testing.T) { + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + 0) + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0}, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + -1) + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + &KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0}, + 1) + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + 0) + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 5}, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + 1) + assertKernelVersion(t, + &KernelVersionInfo{Kernel: 3, Major: 0, Minor: 20}, + &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, + -1) +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go new file mode 100644 index 0000000000..8ca814c1fb --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go @@ -0,0 +1,16 @@ +package kernel + +import ( + "syscall" +) + +type Utsname syscall.Utsname + +func uname() (*syscall.Utsname, error) { + uts := &syscall.Utsname{} + + if err := syscall.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 new file mode 100644 index 0000000000..00c5422589 --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go @@ -0,0 +1,15 @@ +// +build !linux + +package kernel + +import ( + "errors" +) + +type Utsname struct { + Release [65]byte +} + +func uname() (*Utsname, error) { + return nil, errors.New("Kernel version detection is available only on linux") +} diff --git a/libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md b/libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md new file mode 100644 index 0000000000..c88f9b2bdd --- /dev/null +++ b/libnetwork/Godeps/_workspace/src/github.com/godbus/dbus/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# How to Contribute + +## Getting Started + +- Fork the repository on GitHub +- Read the [README](README.markdown) for build and test instructions +- Play with the project, submit bugs, submit patches! + +## Contribution Flow + +This is a rough outline of what a contributor's workflow looks like: + +- Create a topic branch from where you want to base your work (usually master). +- Make commits of logical units. +- Make sure your commit messages are in the proper format (see below). +- Push your changes to a topic branch in your fork of the repository. +- Make sure the tests pass, and add any new tests as appropriate. +- Submit a pull request to the original repository. + +Thanks for your contributions! + +### Format of the Commit Message + +We follow a rough convention for commit messages that is designed to answer two +questions: what changed and why. The subject line should feature the what and +the body of the commit should describe the why. + +``` +scripts: add the test-cluster command + +this uses tmux to setup a test cluster that you can easily kill and +start for debugging. + +Fixes #38 +``` + +The format can be described more formally as follows: + +``` +: + + + +