1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #43804 from thaJeztah/gofmt_119_2

This commit is contained in:
Samuel Karp 2022-07-14 21:29:07 -07:00 committed by GitHub
commit 0136a7c1bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 55 additions and 53 deletions

View file

@ -558,7 +558,7 @@ func (c *client) CreateCheckpoint(ctx context.Context, containerID, checkpointDi
for _, m := range index.Manifests { for _, m := range index.Manifests {
m := m m := m
if m.MediaType == images.MediaTypeContainerd1Checkpoint { if m.MediaType == images.MediaTypeContainerd1Checkpoint {
cpDesc = &m // nolint:gosec cpDesc = &m //nolint:gosec
break break
} }
} }

View file

@ -29,11 +29,11 @@ type tableHandler struct {
var clientWatchTable = map[string]tableHandler{} var clientWatchTable = map[string]tableHandler{}
func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) { func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
diagnostic.DebugHTTPForm(r) diagnostic.DebugHTTPForm(r)
if len(r.Form["tname"]) < 1 { if len(r.Form["tname"]) < 1 {
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path)) rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) // nolint:errcheck diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) //nolint:errcheck
return return
} }
@ -54,11 +54,11 @@ func watchTable(ctx interface{}, w http.ResponseWriter, r *http.Request) {
} }
func watchTableEntries(ctx interface{}, w http.ResponseWriter, r *http.Request) { func watchTableEntries(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
diagnostic.DebugHTTPForm(r) diagnostic.DebugHTTPForm(r)
if len(r.Form["tname"]) < 1 { if len(r.Form["tname"]) < 1 {
rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path)) rsp := diagnostic.WrongCommand(missingParameter, fmt.Sprintf("%s?tname=table_name", r.URL.Path))
diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) // nolint:errcheck diagnostic.HTTPReply(w, rsp, &diagnostic.JSONOutput{}) //nolint:errcheck
return return
} }

View file

@ -623,7 +623,7 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
if id != "" { if id != "" {
c.networkLocker.Lock(id) c.networkLocker.Lock(id)
defer c.networkLocker.Unlock(id) // nolint:errcheck defer c.networkLocker.Unlock(id) //nolint:errcheck
if _, err = c.NetworkByID(id); err == nil { if _, err = c.NetworkByID(id); err == nil {
return nil, NetworkNameError(id) return nil, NetworkNameError(id)
@ -734,7 +734,7 @@ func (c *controller) NewNetwork(networkType, name string, id string, options ...
err = c.addNetwork(network) err = c.addNetwork(network)
if err != nil { if err != nil {
if _, ok := err.(types.MaskableError); ok { // nolint:gosimple if _, ok := err.(types.MaskableError); ok { //nolint:gosimple
// This error can be ignored and set this boolean // This error can be ignored and set this boolean
// value to skip a refcount increment for configOnly networks // value to skip a refcount increment for configOnly networks
skipCfgEpCount = true skipCfgEpCount = true

View file

@ -108,7 +108,7 @@ func (s *Server) DisableDiagnostic() {
s.Lock() s.Lock()
defer s.Unlock() defer s.Unlock()
s.srv.Shutdown(context.Background()) // nolint:errcheck s.srv.Shutdown(context.Background()) //nolint:errcheck
s.srv = nil s.srv = nil
s.enable = 0 s.enable = 0
logrus.Info("Disabling the diagnostic server") logrus.Info("Disabling the diagnostic server")
@ -122,7 +122,7 @@ func (s *Server) IsDiagnosticEnabled() bool {
} }
func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) { func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
_, json := ParseHTTPFormOptions(r) _, json := ParseHTTPFormOptions(r)
rsp := WrongCommand("not implemented", fmt.Sprintf("URL path: %s no method implemented check /help\n", r.URL.Path)) rsp := WrongCommand("not implemented", fmt.Sprintf("URL path: %s no method implemented check /help\n", r.URL.Path))
@ -130,11 +130,11 @@ func notImplemented(ctx interface{}, w http.ResponseWriter, r *http.Request) {
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()}) log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
log.Info("command not implemented done") log.Info("command not implemented done")
HTTPReply(w, rsp, json) // nolint:errcheck HTTPReply(w, rsp, json) //nolint:errcheck
} }
func help(ctx interface{}, w http.ResponseWriter, r *http.Request) { func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
_, json := ParseHTTPFormOptions(r) _, json := ParseHTTPFormOptions(r)
// audit logs // audit logs
@ -147,22 +147,22 @@ func help(ctx interface{}, w http.ResponseWriter, r *http.Request) {
for path := range n.registeredHanders { for path := range n.registeredHanders {
result += fmt.Sprintf("%s\n", path) result += fmt.Sprintf("%s\n", path)
} }
HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), json) // nolint:errcheck HTTPReply(w, CommandSucceed(&StringCmd{Info: result}), json) //nolint:errcheck
} }
} }
func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) { func ready(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
_, json := ParseHTTPFormOptions(r) _, json := ParseHTTPFormOptions(r)
// audit logs // audit logs
log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()}) log := logrus.WithFields(logrus.Fields{"component": "diagnostic", "remoteIP": r.RemoteAddr, "method": caller.Name(0), "url": r.URL.String()})
log.Info("ready done") log.Info("ready done")
HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), json) // nolint:errcheck HTTPReply(w, CommandSucceed(&StringCmd{Info: "OK"}), json) //nolint:errcheck
} }
func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) { func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
r.ParseForm() // nolint:errcheck r.ParseForm() //nolint:errcheck
_, json := ParseHTTPFormOptions(r) _, json := ParseHTTPFormOptions(r)
// audit logs // audit logs
@ -172,10 +172,10 @@ func stackTrace(ctx interface{}, w http.ResponseWriter, r *http.Request) {
path, err := stack.DumpToFile("/tmp/") path, err := stack.DumpToFile("/tmp/")
if err != nil { if err != nil {
log.WithError(err).Error("failed to write goroutines dump") log.WithError(err).Error("failed to write goroutines dump")
HTTPReply(w, FailCommand(err), json) // nolint:errcheck HTTPReply(w, FailCommand(err), json) //nolint:errcheck
} else { } else {
log.Info("stack trace done") log.Info("stack trace done")
HTTPReply(w, CommandSucceed(&StringCmd{Info: fmt.Sprintf("goroutine stacks written to %s", path)}), json) // nolint:errcheck HTTPReply(w, CommandSucceed(&StringCmd{Info: fmt.Sprintf("goroutine stacks written to %s", path)}), json) //nolint:errcheck
} }
} }

View file

@ -120,18 +120,18 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
// If anyone ever comes here and figures out one way or another if we can/should be checking these errors and it turns out we can't... then please document *why* // If anyone ever comes here and figures out one way or another if we can/should be checking these errors and it turns out we can't... then please document *why*
ib, _ := json.Marshal(epMap["ep_iface"]) ib, _ := json.Marshal(epMap["ep_iface"])
json.Unmarshal(ib, &ep.iface) // nolint:errcheck json.Unmarshal(ib, &ep.iface) //nolint:errcheck
jb, _ := json.Marshal(epMap["joinInfo"]) jb, _ := json.Marshal(epMap["joinInfo"])
json.Unmarshal(jb, &ep.joinInfo) // nolint:errcheck json.Unmarshal(jb, &ep.joinInfo) //nolint:errcheck
tb, _ := json.Marshal(epMap["exposed_ports"]) tb, _ := json.Marshal(epMap["exposed_ports"])
var tPorts []types.TransportPort var tPorts []types.TransportPort
json.Unmarshal(tb, &tPorts) // nolint:errcheck json.Unmarshal(tb, &tPorts) //nolint:errcheck
ep.exposedPorts = tPorts ep.exposedPorts = tPorts
cb, _ := json.Marshal(epMap["sandbox"]) cb, _ := json.Marshal(epMap["sandbox"])
json.Unmarshal(cb, &ep.sandboxID) // nolint:errcheck json.Unmarshal(cb, &ep.sandboxID) //nolint:errcheck
if v, ok := epMap["generic"]; ok { if v, ok := epMap["generic"]; ok {
ep.generic = v.(map[string]interface{}) ep.generic = v.(map[string]interface{})
@ -207,17 +207,17 @@ func (ep *endpoint) UnmarshalJSON(b []byte) (err error) {
sal, _ := json.Marshal(epMap["svcAliases"]) sal, _ := json.Marshal(epMap["svcAliases"])
var svcAliases []string var svcAliases []string
json.Unmarshal(sal, &svcAliases) // nolint:errcheck json.Unmarshal(sal, &svcAliases) //nolint:errcheck
ep.svcAliases = svcAliases ep.svcAliases = svcAliases
pc, _ := json.Marshal(epMap["ingressPorts"]) pc, _ := json.Marshal(epMap["ingressPorts"])
var ingressPorts []*PortConfig var ingressPorts []*PortConfig
json.Unmarshal(pc, &ingressPorts) // nolint:errcheck json.Unmarshal(pc, &ingressPorts) //nolint:errcheck
ep.ingressPorts = ingressPorts ep.ingressPorts = ingressPorts
ma, _ := json.Marshal(epMap["myAliases"]) ma, _ := json.Marshal(epMap["myAliases"])
var myAliases []string var myAliases []string
json.Unmarshal(ma, &myAliases) // nolint:errcheck json.Unmarshal(ma, &myAliases) //nolint:errcheck
ep.myAliases = myAliases ep.myAliases = myAliases
return nil return nil
} }

View file

@ -137,7 +137,7 @@ func (epi *endpointInterface) UnmarshalJSON(b []byte) error {
var routes []string var routes []string
// TODO(cpuguy83): linter noticed we don't check the error here... no idea why but it seems like it could introduce problems if we start checking // TODO(cpuguy83): linter noticed we don't check the error here... no idea why but it seems like it could introduce problems if we start checking
json.Unmarshal(rb, &routes) // nolint:errcheck json.Unmarshal(rb, &routes) //nolint:errcheck
epi.routes = make([]*net.IPNet, 0) epi.routes = make([]*net.IPNet, 0)
for _, route := range routes { for _, route := range routes {
@ -444,7 +444,7 @@ func (epj *endpointJoinInfo) UnmarshalJSON(b []byte) error {
// This is why I'm not adding the error check. // This is why I'm not adding the error check.
// //
// In any case for posterity please if you figure this out document it or check the error // In any case for posterity please if you figure this out document it or check the error
json.Unmarshal(tb, &tStaticRoute) // nolint:errcheck json.Unmarshal(tb, &tStaticRoute) //nolint:errcheck
} }
var StaticRoutes []*types.StaticRoute var StaticRoutes []*types.StaticRoute
for _, r := range tStaticRoute { for _, r := range tStaticRoute {

View file

@ -630,7 +630,7 @@ func TestIpamReleaseOnNetDriverFailures(t *testing.T) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
defer ep.Delete(false) // nolint:errcheck defer ep.Delete(false) //nolint:errcheck
expectedIP, _ := types.ParseCIDR("10.35.0.1/16") expectedIP, _ := types.ParseCIDR("10.35.0.1/16")
if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) { if !types.CompareIPNet(ep.Info().Iface().Address(), expectedIP) {

View file

@ -993,7 +993,7 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error {
n.Unlock() n.Unlock()
c.networkLocker.Lock(id) c.networkLocker.Lock(id)
defer c.networkLocker.Unlock(id) // nolint:errcheck defer c.networkLocker.Unlock(id) //nolint:errcheck
n, err := c.getNetworkFromStore(id) n, err := c.getNetworkFromStore(id)
if err != nil { if err != nil {
@ -1027,7 +1027,7 @@ func (n *network) delete(force bool, rmLBEndpoint bool) error {
// continue deletion when force is true even on error // continue deletion when force is true even on error
logrus.Warnf("Error deleting load balancer sandbox: %v", err) logrus.Warnf("Error deleting load balancer sandbox: %v", err)
} }
//Reload the network from the store to update the epcnt. // Reload the network from the store to update the epcnt.
n, err = c.getNetworkFromStore(id) n, err = c.getNetworkFromStore(id)
if err != nil { if err != nil {
return &UnknownNetworkError{name: name, id: id} return &UnknownNetworkError{name: name, id: id}
@ -1165,7 +1165,7 @@ func (n *network) CreateEndpoint(name string, options ...EndpointOption) (Endpoi
} }
n.ctrlr.networkLocker.Lock(n.id) n.ctrlr.networkLocker.Lock(n.id)
defer n.ctrlr.networkLocker.Unlock(n.id) // nolint:errcheck defer n.ctrlr.networkLocker.Unlock(n.id) //nolint:errcheck
return n.createEndpoint(name, options...) return n.createEndpoint(name, options...)

View file

@ -84,7 +84,7 @@ func TestGenerateMissingField(t *testing.T) {
} }
func TestFieldCannotBeSet(t *testing.T) { func TestFieldCannotBeSet(t *testing.T) {
type Model struct{ foo int } // nolint:structcheck type Model struct{ foo int } //nolint:structcheck
_, err := GenerateFromModel(Generic{"foo": "bar"}, Model{}) _, err := GenerateFromModel(Generic{"foo": "bar"}, Model{})
if _, ok := err.(CannotSetFieldError); !ok { if _, ok := err.(CannotSetFieldError); !ok {

View file

@ -64,7 +64,7 @@ const (
ptrIPv4domain = ".in-addr.arpa." ptrIPv4domain = ".in-addr.arpa."
ptrIPv6domain = ".ip6.arpa." ptrIPv6domain = ".ip6.arpa."
respTTL = 600 respTTL = 600
maxExtDNS = 3 //max number of external servers to try maxExtDNS = 3 // max number of external servers to try
extIOTimeout = 4 * time.Second extIOTimeout = 4 * time.Second
defaultRespSize = 512 defaultRespSize = 512
maxConcurrent = 1024 maxConcurrent = 1024
@ -177,10 +177,10 @@ func (r *resolver) Stop() {
defer func() { <-r.startCh }() defer func() { <-r.startCh }()
if r.server != nil { if r.server != nil {
r.server.Shutdown() // nolint:errcheck r.server.Shutdown() //nolint:errcheck
} }
if r.tcpServer != nil { if r.tcpServer != nil {
r.tcpServer.Shutdown() // nolint:errcheck r.tcpServer.Shutdown() //nolint:errcheck
} }
r.conn = nil r.conn = nil
r.tcpServer = nil r.tcpServer = nil
@ -214,7 +214,7 @@ func setCommonFlags(msg *dns.Msg) {
func shuffleAddr(addr []net.IP) []net.IP { func shuffleAddr(addr []net.IP) []net.IP {
for i := len(addr) - 1; i > 0; i-- { for i := len(addr) - 1; i > 0; i-- {
r := rand.Intn(i + 1) // nolint:gosec // gosec complains about the use of rand here. It should be fine. r := rand.Intn(i + 1) //nolint:gosec // gosec complains about the use of rand here. It should be fine.
addr[i], addr[r] = addr[r], addr[i] addr[i], addr[r] = addr[r], addr[i]
} }
return addr return addr

View file

@ -252,7 +252,7 @@ func TestDNSProxyServFail(t *testing.T) {
srvErrCh <- server.ListenAndServe() srvErrCh <- server.ListenAndServe()
}() }()
defer func() { defer func() {
server.Shutdown() // nolint:errcheck server.Shutdown() //nolint:errcheck
if err := <-srvErrCh; err != nil { if err := <-srvErrCh; err != nil {
t.Error(err) t.Error(err)
} }

View file

@ -93,12 +93,12 @@ type sandbox struct {
// These are the container configs used to customize container /etc/hosts file. // These are the container configs used to customize container /etc/hosts file.
type hostsPathConfig struct { type hostsPathConfig struct {
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are // Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
hostName string // nolint:structcheck hostName string //nolint:structcheck
domainName string // nolint:structcheck domainName string //nolint:structcheck
hostsPath string // nolint:structcheck hostsPath string //nolint:structcheck
originHostsPath string // nolint:structcheck originHostsPath string //nolint:structcheck
extraHosts []extraHost // nolint:structcheck extraHosts []extraHost //nolint:structcheck
parentUpdates []parentUpdate // nolint:structcheck parentUpdates []parentUpdate //nolint:structcheck
} }
type parentUpdate struct { type parentUpdate struct {
@ -115,12 +115,12 @@ type extraHost struct {
// These are the container configs used to customize container /etc/resolv.conf file. // These are the container configs used to customize container /etc/resolv.conf file.
type resolvConfPathConfig struct { type resolvConfPathConfig struct {
// Note(cpuguy83): The linter is drunk and says none of these fields are used while they are // Note(cpuguy83): The linter is drunk and says none of these fields are used while they are
resolvConfPath string // nolint:structcheck resolvConfPath string //nolint:structcheck
originResolvConfPath string // nolint:structcheck originResolvConfPath string //nolint:structcheck
resolvConfHashFile string // nolint:structcheck resolvConfHashFile string //nolint:structcheck
dnsList []string // nolint:structcheck dnsList []string //nolint:structcheck
dnsSearchList []string // nolint:structcheck dnsSearchList []string //nolint:structcheck
dnsOptionsList []string // nolint:structcheck dnsOptionsList []string //nolint:structcheck
} }
type containerConfig struct { type containerConfig struct {
@ -412,8 +412,8 @@ func (sb *sandbox) updateGateway(ep *endpoint) error {
if osSbox == nil { if osSbox == nil {
return nil return nil
} }
osSbox.UnsetGateway() // nolint:errcheck osSbox.UnsetGateway() //nolint:errcheck
osSbox.UnsetGatewayIPv6() // nolint:errcheck osSbox.UnsetGatewayIPv6() //nolint:errcheck
if ep == nil { if ep == nil {
return nil return nil

View file

@ -235,7 +235,7 @@ func (c *controller) addServiceBinding(svcName, svcID, nID, eID, containerName s
// state in the c.serviceBindings map and it's sub-maps. Also, // state in the c.serviceBindings map and it's sub-maps. Also,
// always lock network ID before services to avoid deadlock. // always lock network ID before services to avoid deadlock.
c.networkLocker.Lock(nID) c.networkLocker.Lock(nID)
defer c.networkLocker.Unlock(nID) // nolint:errcheck defer c.networkLocker.Unlock(nID) //nolint:errcheck
n, err := c.NetworkByID(nID) n, err := c.NetworkByID(nID)
if err != nil { if err != nil {

View file

@ -15,7 +15,8 @@ import (
) )
// Same as DM_DEVICE_* enum values from libdevmapper.h // Same as DM_DEVICE_* enum values from libdevmapper.h
// nolint: deadcode,unused,varcheck //
//nolint:deadcode,unused,varcheck
const ( const (
deviceCreate TaskType = iota deviceCreate TaskType = iota
deviceReload deviceReload

View file

@ -21,7 +21,8 @@ const extName = "VolumeDriver"
// volumeDriver defines the available functions that volume plugins must implement. // volumeDriver defines the available functions that volume plugins must implement.
// This interface is only defined to generate the proxy objects. // This interface is only defined to generate the proxy objects.
// It's not intended to be public or reused. // It's not intended to be public or reused.
// nolint: deadcode,unused,varcheck //
//nolint:deadcode,unused,varcheck
type volumeDriver interface { type volumeDriver interface {
// Create a volume with the given name // Create a volume with the given name
Create(name string, opts map[string]string) (err error) Create(name string, opts map[string]string) (err error)