Skip to content

Commit

Permalink
Fix cni conf
Browse files Browse the repository at this point in the history
Signed-off-by: Yakul Garg <2000yeshu@gmail.com>
  • Loading branch information
2000yeshu committed Mar 28, 2024
1 parent 5101b94 commit e4fec44
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cmd/ctr/commands/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var Command = cli.Command{
Name: "cni",
Usage: "Enable cni networking for the container",
},
cli.Uint64Flag{
cli.StringFlag{
Name: "cni-bandwidth-conf",
Usage: "Cni conf for bandwidth plugin",
},
Expand Down Expand Up @@ -186,8 +186,14 @@ var Command = cli.Command{
}
var network gocni.CNI
if enableCNI {
if network, err = gocni.New(gocni.WithDefaultConf, gocni.WithConfFile(context.String("cni-bandwidth-conf"))); err != nil {
return err
if context.String("cni-bandwidth-conf") == "" {
if network, err = gocni.New(gocni.WithDefaultConf); err != nil {
return err
}
} else {
if network, err = gocni.New(gocni.WithDefaultConf, gocni.WithConfFile(context.String("cni-bandwidth-conf"))); err != nil {
return err
}
}
}

Expand Down

0 comments on commit e4fec44

Please sign in to comment.