本文整理匯總了Golang中github.com/docker/libnetwork/driverapi.InterfaceInfo.SetIPAliases方法的典型用法代碼示例。如果您正苦於以下問題:Golang InterfaceInfo.SetIPAliases方法的具體用法?Golang InterfaceInfo.SetIPAliases怎麽用?Golang InterfaceInfo.SetIPAliases使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/libnetwork/driverapi.InterfaceInfo
的用法示例。
在下文中一共展示了InterfaceInfo.SetIPAliases方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: CreateEndpoint
func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo, epOptions map[string]interface{}) error {
if ifInfo == nil {
return fmt.Errorf("must not be called with nil InterfaceInfo")
}
reqIface := &api.EndpointInterface{}
if ifInfo.Address() != nil {
reqIface.Address = ifInfo.Address().String()
}
if ifInfo.AddressIPv6() != nil {
reqIface.AddressIPv6 = ifInfo.AddressIPv6().String()
}
if ifInfo.MacAddress() != nil {
reqIface.MacAddress = ifInfo.MacAddress().String()
}
if ifInfo.IPAliases() != nil {
var aliases []string
for _, ips := range ifInfo.IPAliases() {
aliases = append(aliases, ips.String())
}
reqIface.IPAliases = aliases
}
create := &api.CreateEndpointRequest{
NetworkID: nid,
EndpointID: eid,
Interface: reqIface,
Options: epOptions,
}
var res api.CreateEndpointResponse
if err := d.call("CreateEndpoint", create, &res); err != nil {
return err
}
inIface, err := parseInterface(res)
if err != nil {
return err
}
if inIface == nil {
// Remote driver did not set any field
return nil
}
if inIface.MacAddress != nil {
if err := ifInfo.SetMacAddress(inIface.MacAddress); err != nil {
return errorWithRollback(fmt.Sprintf("driver modified interface MAC address: %v", err), d.DeleteEndpoint(nid, eid))
}
}
if inIface.Address != nil {
if err := ifInfo.SetIPAddress(inIface.Address); err != nil {
return errorWithRollback(fmt.Sprintf("driver modified interface address: %v", err), d.DeleteEndpoint(nid, eid))
}
}
if inIface.AddressIPv6 != nil {
if err := ifInfo.SetIPAddress(inIface.AddressIPv6); err != nil {
return errorWithRollback(fmt.Sprintf("driver modified interface address: %v", err), d.DeleteEndpoint(nid, eid))
}
}
if inIface.IPAliases != nil {
if err := ifInfo.SetIPAliases(inIface.IPAliases); err != nil {
return errorWithRollback(fmt.Sprintf("driver modified interface aliases: %v", err), d.DeleteEndpoint(nid, eid))
}
}
return nil
}