enable staticcheck linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@ -104,8 +104,6 @@ func getBandwidth(conf *PluginConf) *BandwidthEntry {
|
||||
|
||||
func validateRateAndBurst(rate, burst uint64) error {
|
||||
switch {
|
||||
case burst < 0 || rate < 0:
|
||||
return fmt.Errorf("rate and burst must be a positive integer")
|
||||
case burst == 0 && rate != 0:
|
||||
return fmt.Errorf("if rate is set, burst must also be set")
|
||||
case rate == 0 && burst != 0:
|
||||
|
@ -84,8 +84,10 @@ var _ = Describe("portmapping configuration", func() {
|
||||
Expect(c.Name).To(Equal("test"))
|
||||
|
||||
n, err := types.ParseCIDR("10.0.0.2/24")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(c.ContIPv4).To(Equal(*n))
|
||||
n, err = types.ParseCIDR("2001:db8:1::2/64")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(c.ContIPv6).To(Equal(*n))
|
||||
})
|
||||
|
||||
@ -199,6 +201,7 @@ var _ = Describe("portmapping configuration", func() {
|
||||
}))
|
||||
|
||||
n, err := types.ParseCIDR("10.0.0.2/24")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fillDnatRules(&ch, conf, *n)
|
||||
|
||||
Expect(ch.entryRules).To(Equal([][]string{
|
||||
@ -249,6 +252,7 @@ var _ = Describe("portmapping configuration", func() {
|
||||
ch.entryRules = nil
|
||||
|
||||
n, err = types.ParseCIDR("2001:db8::2/64")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fillDnatRules(&ch, conf, *n)
|
||||
|
||||
Expect(ch.rules).To(Equal([][]string{
|
||||
@ -277,6 +281,7 @@ var _ = Describe("portmapping configuration", func() {
|
||||
conf.SNAT = &fvar
|
||||
|
||||
n, err = types.ParseCIDR("10.0.0.2/24")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fillDnatRules(&ch, conf, *n)
|
||||
Expect(ch.rules).To(Equal([][]string{
|
||||
{"-p", "tcp", "--dport", "8080", "-j", "DNAT", "--to-destination", "10.0.0.2:80"},
|
||||
@ -316,6 +321,7 @@ var _ = Describe("portmapping configuration", func() {
|
||||
|
||||
ch = genDnatChain(conf.Name, containerID)
|
||||
n, err := types.ParseCIDR("10.0.0.2/24")
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
fillDnatRules(&ch, conf, *n)
|
||||
Expect(ch.rules).To(Equal([][]string{
|
||||
{"-p", "tcp", "--dport", "8080", "-s", "10.0.0.2/24", "-j", "PLZ-SET-MARK"},
|
||||
|
@ -156,6 +156,9 @@ func cmdCheck(args *skel.CmdArgs) error {
|
||||
return err
|
||||
}
|
||||
vrfInterfaces, err := assignedInterfaces(vrf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
found := false
|
||||
for _, intf := range vrfInterfaces {
|
||||
@ -165,10 +168,13 @@ func cmdCheck(args *skel.CmdArgs) error {
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return fmt.Errorf("Failed to find %s associated to vrf %s", args.IfName, conf.VRFName)
|
||||
return fmt.Errorf("failed to find %s associated to vrf %s", args.IfName, conf.VRFName)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -167,6 +167,7 @@ var _ = Describe("vrf plugin", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
return nil
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = targetNS.Do(func(ns.NetNS) error {
|
||||
defer GinkgoRecover()
|
||||
@ -296,6 +297,7 @@ var _ = Describe("vrf plugin", func() {
|
||||
link, err := netlink.LinkByName(IF0Name)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
addresses, err := netlink.AddrList(link, netlink.FAMILY_ALL)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(addresses)).To(Equal(1))
|
||||
Expect(addresses[0].IP.Equal(addr0.IP)).To(BeTrue())
|
||||
Expect(addresses[0].Mask).To(Equal(addr0.Mask))
|
||||
@ -313,6 +315,7 @@ var _ = Describe("vrf plugin", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
addresses, err := netlink.AddrList(link, netlink.FAMILY_ALL)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(addresses)).To(Equal(1))
|
||||
Expect(addresses[0].IP.Equal(addr1.IP)).To(BeTrue())
|
||||
Expect(addresses[0].Mask).To(Equal(addr1.Mask))
|
||||
|
Reference in New Issue
Block a user