Merge pull request #171 from steveeJ/bump-cni

vendoring: bump coreos/go-iptables to 0.1.0
This commit is contained in:
Zach Gershman 2016-03-31 08:46:55 -07:00
commit bacaa11d2d
2 changed files with 12 additions and 16 deletions

3
Godeps/Godeps.json generated
View File

@ -7,7 +7,8 @@
"Deps": [
{
"ImportPath": "github.com/coreos/go-iptables/iptables",
"Rev": "90456be57fcb8185b264b77ce42a9539df42df25"
"Comment": "v0.1.0",
"Rev": "fbb73372b87f6e89951c2b6b31470c2c9d5cfae3"
},
{
"ImportPath": "github.com/coreos/go-systemd/activation",

View File

@ -18,7 +18,6 @@ import (
"bytes"
"fmt"
"io"
"log"
"os/exec"
"regexp"
"strconv"
@ -44,8 +43,6 @@ type IPTables struct {
path string
hasCheck bool
hasWait bool
fmu *fileLock
}
func New() (*IPTables, error) {
@ -55,21 +52,13 @@ func New() (*IPTables, error) {
}
checkPresent, waitPresent, err := getIptablesCommandSupport()
if err != nil {
log.Printf("Error checking iptables version, assuming version at least 1.4.20: %v", err)
checkPresent = true
waitPresent = true
return nil, fmt.Errorf("error checking iptables version: %v", err)
}
ipt := IPTables{
path: path,
hasCheck: checkPresent,
hasWait: waitPresent,
}
if !waitPresent {
ipt.fmu, err = newXtablesFileLock()
if err != nil {
return nil, err
}
}
return &ipt, nil
}
@ -81,10 +70,11 @@ func (ipt *IPTables) Exists(table, chain string, rulespec ...string) (bool, erro
}
cmd := append([]string{"-t", table, "-C", chain}, rulespec...)
err := ipt.run(cmd...)
eerr, eok := err.(*Error)
switch {
case err == nil:
return true, nil
case err.(*Error).ExitStatus() == 1:
case eok && eerr.ExitStatus() == 1:
return false, nil
default:
return false, err
@ -148,10 +138,11 @@ func (ipt *IPTables) NewChain(table, chain string) error {
func (ipt *IPTables) ClearChain(table, chain string) error {
err := ipt.NewChain(table, chain)
eerr, eok := err.(*Error)
switch {
case err == nil:
return nil
case err.(*Error).ExitStatus() == 1:
case eok && eerr.ExitStatus() == 1:
// chain already exists. Flush (clear) it.
return ipt.run("-t", table, "-F", chain)
default:
@ -183,7 +174,11 @@ func (ipt *IPTables) runWithOutput(args []string, stdout io.Writer) error {
if ipt.hasWait {
args = append(args, "--wait")
} else {
ul, err := ipt.fmu.tryLock()
fmu, err := newXtablesFileLock()
if err != nil {
return err
}
ul, err := fmu.tryLock()
if err != nil {
return err
}