(ep opts.NetworkAttachmentOpts)
| 857 | } |
| 858 | |
| 859 | func parseNetworkAttachmentOpt(ep opts.NetworkAttachmentOpts) (*network.EndpointSettings, error) { |
| 860 | if strings.TrimSpace(ep.Target) == "" { |
| 861 | return nil, errors.New("no name set for network") |
| 862 | } |
| 863 | if !container.NetworkMode(ep.Target).IsUserDefined() { |
| 864 | if len(ep.Aliases) > 0 { |
| 865 | return nil, errors.New("network-scoped aliases are only supported for user-defined networks") |
| 866 | } |
| 867 | if len(ep.Links) > 0 { |
| 868 | return nil, errors.New("links are only supported for user-defined networks") |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | epConfig := &network.EndpointSettings{ |
| 873 | GwPriority: ep.GwPriority, |
| 874 | } |
| 875 | epConfig.Aliases = append(epConfig.Aliases, ep.Aliases...) |
| 876 | if len(ep.DriverOpts) > 0 { |
| 877 | epConfig.DriverOpts = make(map[string]string) |
| 878 | epConfig.DriverOpts = ep.DriverOpts |
| 879 | } |
| 880 | if len(ep.Links) > 0 { |
| 881 | epConfig.Links = ep.Links |
| 882 | } |
| 883 | if ep.IPv4Address.IsValid() || ep.IPv6Address.IsValid() || len(ep.LinkLocalIPs) > 0 { |
| 884 | epConfig.IPAMConfig = &network.EndpointIPAMConfig{ |
| 885 | IPv4Address: ep.IPv4Address, |
| 886 | IPv6Address: ep.IPv6Address, |
| 887 | LinkLocalIPs: ep.LinkLocalIPs, |
| 888 | } |
| 889 | } |
| 890 | if ep.MacAddress != "" { |
| 891 | ma, err := net.ParseMAC(strings.TrimSpace(ep.MacAddress)) |
| 892 | if err != nil { |
| 893 | return nil, fmt.Errorf("%s is not a valid mac address", ep.MacAddress) |
| 894 | } |
| 895 | epConfig.MacAddress = network.HardwareAddr(ma) |
| 896 | } |
| 897 | return epConfig, nil |
| 898 | } |
| 899 | |
| 900 | func convertToStandardNotation(ports []string) ([]string, error) { |
| 901 | optsList := []string{} |
no test coverage detected
searching dependent graphs…