diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-09-20 16:53:21 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-09-20 16:53:21 +0200 |
commit | c3a23ce2f5140c57ca452fe83af809bdedb1b10a (patch) | |
tree | 0656696c0ce94b85e1631d8d1e15f5a95d7490e0 /plugins | |
parent | 2ca19cca4d3019c903000fe57053b483ac0745c2 (diff) |
use errors.Errorf instead of fmt.Errorf
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/meta/dnsname/files.go | 3 | ||||
-rw-r--r-- | plugins/meta/dnsname/main.go | 11 | ||||
-rw-r--r-- | plugins/meta/dnsname/result.go | 4 | ||||
-rw-r--r-- | plugins/meta/dnsname/service.go | 3 |
4 files changed, 10 insertions, 11 deletions
diff --git a/plugins/meta/dnsname/files.go b/plugins/meta/dnsname/files.go index c0f1ee8..16d7810 100644 --- a/plugins/meta/dnsname/files.go +++ b/plugins/meta/dnsname/files.go @@ -10,9 +10,8 @@ import ( "strings" "text/template" - "github.com/coreos/go-iptables/iptables" - "github.com/containernetworking/plugins/plugins/ipam/host-local/backend/disk" + "github.com/coreos/go-iptables/iptables" "github.com/sirupsen/logrus" ) diff --git a/plugins/meta/dnsname/main.go b/plugins/meta/dnsname/main.go index 7623d41..114b16b 100644 --- a/plugins/meta/dnsname/main.go +++ b/plugins/meta/dnsname/main.go @@ -28,7 +28,6 @@ package main import ( "encoding/json" - "fmt" "io/ioutil" "os" "os/exec" @@ -52,7 +51,7 @@ func cmdAdd(args *skel.CmdArgs) error { return errors.Wrap(err, "failed to parse config") } if netConf.PrevResult == nil { - return fmt.Errorf("must be called as chained plugin") + return errors.Errorf("must be called as chained plugin") } ips, err := getIPs(result) if err != nil { @@ -163,7 +162,7 @@ func cmdCheck(args *skel.CmdArgs) error { // Ensure we have previous result. if result == nil { - return fmt.Errorf("Required prevResult missing") + return errors.Errorf("Required prevResult missing") } dnsNameConf, err := newDNSMasqFile(netConf.DomainName, result.Interfaces[0].Name, netConf.Name) if err != nil { @@ -191,7 +190,7 @@ func cmdCheck(args *skel.CmdArgs) error { // Ensure the dnsmasq instance is running if !isRunning(pid) { - return fmt.Errorf("dnsmasq instance not running") + return errors.Errorf("dnsmasq instance not running") } // Above will make sure the pidfile exists files, err := ioutil.ReadDir(dnsNameConfPath) @@ -202,10 +201,10 @@ func cmdCheck(args *skel.CmdArgs) error { conffiles = append(conffiles, f.Name()) } if !stringInSlice("addnhosts", conffiles) { - return fmt.Errorf("addnhost file missing from configuration") + return errors.Errorf("addnhost file missing from configuration") } if !stringInSlice("dnsmasq.conf", conffiles) { - return fmt.Errorf("dnsmasq.conf file missing from configuration") + return errors.Errorf("dnsmasq.conf file missing from configuration") } return nil } diff --git a/plugins/meta/dnsname/result.go b/plugins/meta/dnsname/result.go index b2e78a1..3d46029 100644 --- a/plugins/meta/dnsname/result.go +++ b/plugins/meta/dnsname/result.go @@ -1,10 +1,10 @@ package main import ( - "fmt" "net" "github.com/containernetworking/cni/pkg/types/current" + "github.com/pkg/errors" ) // getIPs iterates a result and returns all the IP addresses @@ -24,7 +24,7 @@ func getIPs(r *current.Result) ([]*net.IPNet, error) { if isInterfaceIndexSandox(*ip.Interface, r) { ips = append(ips, &ip.Address) } else { - return nil, fmt.Errorf("unable to check if interface has a sandbox due to index being out of range") + return nil, errors.Errorf("unable to check if interface has a sandbox due to index being out of range") } } } diff --git a/plugins/meta/dnsname/service.go b/plugins/meta/dnsname/service.go index 3156c1f..c4b8b0f 100644 --- a/plugins/meta/dnsname/service.go +++ b/plugins/meta/dnsname/service.go @@ -10,6 +10,7 @@ import ( "strings" "syscall" + "github.com/pkg/errors" "golang.org/x/sys/unix" ) @@ -17,7 +18,7 @@ import ( func newDNSMasqFile(domainName, networkInterface, networkName string) (dnsNameFile, error) { dnsMasqBinary, err := exec.LookPath("dnsmasq") if err != nil { - return dnsNameFile{}, fmt.Errorf("the dnsmasq cni plugin requires the dnsmasq binary be in PATH") + return dnsNameFile{}, errors.Errorf("the dnsmasq cni plugin requires the dnsmasq binary be in PATH") } masqConf := dnsNameFile{ ConfigFile: makePath(networkName, confFileName), |