plugins: correctly output build version, cosmetic cleanups

Now that libcni has the ability to print a version message, plumb it
through correctly.

While we're at it,
- fix import paths
- run gofmt
- add some more comments to sample
- add container runtime swappability for release
This commit is contained in:
Casey Callendrello
2019-04-15 16:13:02 +02:00
parent 6733d30762
commit 72f2a1ffd4
26 changed files with 139 additions and 73 deletions

View File

@ -27,6 +27,7 @@ import (
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/current"
"github.com/containernetworking/cni/pkg/version"
bv "github.com/containernetworking/plugins/pkg/utils/buildversion"
)
const defaultSocketPath = "/run/cni/dhcp.sock"
@ -51,8 +52,7 @@ func main() {
os.Exit(1)
}
} else {
// TODO: implement plugin version
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, "TODO")
skel.PluginMain(cmdAdd, cmdCheck, cmdDel, version.All, bv.BuildString("dhcp"))
}
}

View File

@ -98,7 +98,7 @@ func parseCIDRRoutes(opts dhcp4.Options) []*types.Route {
}
routes = append(routes, rt)
opt = opt[octets+5 : len(opt)]
opt = opt[octets+5:]
}
}
return routes

View File

@ -24,14 +24,14 @@ import (
func validateRoutes(t *testing.T, routes []*types.Route) {
expected := []*types.Route{
&types.Route{
{
Dst: net.IPNet{
IP: net.IPv4(10, 0, 0, 0),
Mask: net.CIDRMask(8, 32),
},
GW: net.IPv4(10, 1, 2, 3),
},
&types.Route{
{
Dst: net.IPNet{
IP: net.IPv4(192, 168, 1, 0),
Mask: net.CIDRMask(24, 32),