github.com/openshift/dpu-operator@v0.0.0-20240502153209-3af840d137c2/dpu-cni/dpu-cni.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "go/types" 6 "os" 7 8 "github.com/containernetworking/cni/pkg/skel" 9 "github.com/containernetworking/cni/pkg/version" 10 bv "github.com/containernetworking/plugins/pkg/utils/buildversion" 11 "github.com/openshift/dpu-operator/dpu-cni/pkgs/cni" 12 "github.com/urfave/cli/v2" 13 ) 14 15 const cniName string = "dpu-cni" 16 17 func main() { 18 c := cli.NewApp() 19 c.Name = cniName 20 c.Usage = "a CNI plugin to set up or tear down a container's network with DPUs" 21 c.Version = "0.0.2" 22 23 p := cni.NewCNIPlugin() 24 c.Action = func(ctx *cli.Context) error { 25 skel.PluginMain( 26 p.CmdAdd, 27 p.CmdCheck, 28 p.CmdDel, 29 version.All, 30 bv.BuildString(cniName)) 31 return nil 32 } 33 34 if err := c.Run(os.Args); err != nil { 35 // Print the error to stdout in conformance with the CNI spec 36 e, ok := err.(*types.Error) 37 if !ok { 38 e = &types.Error{Msg: err.Error()} 39 } 40 fmt.Printf("e: %v\n", e) 41 } 42 }