diff --git a/libnetwork/drivers/overlay/ovmanager/ovmanager.go b/libnetwork/drivers/overlay/ovmanager/ovmanager.go index fcb0ea9cff..effd53005f 100644 --- a/libnetwork/drivers/overlay/ovmanager/ovmanager.go +++ b/libnetwork/drivers/overlay/ovmanager/ovmanager.go @@ -117,9 +117,9 @@ func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, n.subnets = append(n.subnets, s) } - val := fmt.Sprintf("%d", n.subnets[0].vni) + val := strconv.FormatUint(uint64(n.subnets[0].vni), 10) for _, s := range n.subnets[1:] { - val = val + fmt.Sprintf(",%d", s.vni) + val = val + "," + strconv.FormatUint(uint64(s.vni), 10) } opts[netlabel.OverlayVxlanIDList] = val diff --git a/libnetwork/drivers/windows/windows.go b/libnetwork/drivers/windows/windows.go index 5a0496fded..7695dbc9e5 100644 --- a/libnetwork/drivers/windows/windows.go +++ b/libnetwork/drivers/windows/windows.go @@ -71,12 +71,12 @@ type hnsEndpoint struct { nid string profileID string Type string - //Note: Currently, the sandboxID is the same as the containerID since windows does - //not expose the sandboxID. - //In the future, windows will support a proper sandboxID that is different - //than the containerID. - //Therefore, we are using sandboxID now, so that we won't have to change this code - //when windows properly supports a sandboxID. + // Note: Currently, the sandboxID is the same as the containerID since windows does + // not expose the sandboxID. + // In the future, windows will support a proper sandboxID that is different + // than the containerID. + // Therefore, we are using sandboxID now, so that we won't have to change this code + // when windows properly supports a sandboxID. sandboxID string macAddress net.HardwareAddr epOption *endpointOption // User specified parameters @@ -377,8 +377,8 @@ func (d *driver) CreateNetwork(id string, option map[string]interface{}, nInfo d for i, subnet := range hnsresponse.Subnets { var gwIP, subnetIP *net.IPNet - //The gateway returned from HNS is an IPAddress. - //We need to convert it to an IPNet to use as the Gateway of driverapi.IPAMData struct + // The gateway returned from HNS is an IPAddress. + // We need to convert it to an IPNet to use as the Gateway of driverapi.IPAMData struct gwCIDR := subnet.GatewayAddress + "/32" _, gwIP, err = net.ParseCIDR(gwCIDR) if err != nil { diff --git a/libnetwork/networkdb/networkdbdiagnostic.go b/libnetwork/networkdb/networkdbdiagnostic.go index f729930314..c1cbe130ac 100644 --- a/libnetwork/networkdb/networkdbdiagnostic.go +++ b/libnetwork/networkdb/networkdbdiagnostic.go @@ -61,7 +61,7 @@ func dbJoin(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func dbPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -118,7 +118,7 @@ func dbClusterPeers(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -167,7 +167,7 @@ func dbCreateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -215,7 +215,7 @@ func dbUpdateEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -252,7 +252,7 @@ func dbDeleteEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -298,7 +298,7 @@ func dbGetEntry(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -330,7 +330,7 @@ func dbJoinNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -362,7 +362,7 @@ func dbLeaveNetwork(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(nil), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -410,7 +410,7 @@ func dbGetTable(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, diagnostic.CommandSucceed(rsp), json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } func dbNetworkStats(ctx interface{}, w http.ResponseWriter, r *http.Request) { @@ -448,5 +448,5 @@ func dbNetworkStats(ctx interface{}, w http.ResponseWriter, r *http.Request) { diagnostic.HTTPReply(w, rsp, json) return } - diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf("%s", dbNotAvailable)), json) + diagnostic.HTTPReply(w, diagnostic.FailCommand(fmt.Errorf(dbNotAvailable)), json) } diff --git a/libnetwork/service_linux.go b/libnetwork/service_linux.go index 1900c75fee..bbe23783c7 100644 --- a/libnetwork/service_linux.go +++ b/libnetwork/service_linux.go @@ -600,7 +600,7 @@ func invokeFWMarker(path string, vip net.IP, fwMark uint32, ingressPorts []*Port cmd := &exec.Cmd{ Path: reexec.Self(), - Args: append([]string{"fwmarker"}, path, vip.String(), fmt.Sprintf("%d", fwMark), addDelOpt, ingressPortsFile, eIP.String(), lbMode), + Args: append([]string{"fwmarker"}, path, vip.String(), strconv.FormatUint(uint64(fwMark), 10), addDelOpt, ingressPortsFile, eIP.String(), lbMode), Stdout: os.Stdout, Stderr: os.Stderr, } diff --git a/libnetwork/types/types.go b/libnetwork/types/types.go index e4ade05902..caf9328bae 100644 --- a/libnetwork/types/types.go +++ b/libnetwork/types/types.go @@ -5,6 +5,7 @@ import ( "bytes" "fmt" "net" + "strconv" "strings" "github.com/ishidawataru/sctp" @@ -202,7 +203,7 @@ func (p Protocol) String() string { case SCTP: return "sctp" default: - return fmt.Sprintf("%d", p) + return strconv.Itoa(int(p)) } }