本文整理匯總了Golang中github.com/containernetworking/cni/pkg/types.Result.IP4方法的典型用法代碼示例。如果您正苦於以下問題:Golang Result.IP4方法的具體用法?Golang Result.IP4怎麽用?Golang Result.IP4使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/containernetworking/cni/pkg/types.Result
的用法示例。
在下文中一共展示了Result.IP4方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createCNIReply
func createCNIReply(ipamConf *ipam.IPAMRep) error {
v6Routes := []cniTypes.Route{}
v4Routes := []cniTypes.Route{}
for _, r := range ipamConf.IP6.Routes {
newRoute := cniTypes.Route{
Dst: r.Destination,
}
if r.NextHop != nil {
newRoute.GW = r.NextHop
}
v6Routes = append(v6Routes, newRoute)
}
r := cniTypes.Result{
IP6: &cniTypes.IPConfig{
IP: ipamConf.IP6.IP,
Gateway: ipamConf.IP6.Gateway,
Routes: v6Routes,
},
}
if ipamConf.IP4 != nil {
for _, r := range ipamConf.IP4.Routes {
newRoute := cniTypes.Route{
Dst: r.Destination,
}
if r.NextHop != nil {
newRoute.GW = r.NextHop
}
v4Routes = append(v4Routes, newRoute)
}
r.IP4 = &cniTypes.IPConfig{
IP: ipamConf.IP4.IP,
Gateway: ipamConf.IP4.Gateway,
Routes: v4Routes,
}
}
return r.Print()
}