Skip to content

Commit

Permalink
fix golangci-lint warnings
Browse files Browse the repository at this point in the history
Fix the following issues:

  etcd/etcd.go:39:50: S1002: should omit comparison to bool constant, can be simplified to `match` (gosimple)
  	if match, _ := regexp.Match("0\\.4\\.*", body); match == true {
  etcd/etcd.go:4:2: SA1019: "io/ioutil" has been deprecated since Go 1.19: As of Go 1.16, the same functionality is now provided by package [io] or package [os], and those implementations should be preferred in new code. See the specific function documentation for details. (staticcheck)
  	"io/ioutil"
  zookeeper/zookeeper.go:30:11: Error return value of `c.Create` is not checked (errcheck)
  		c.Create(uri.Path, []byte{}, 0, zk.WorldACL(zk.PermAll))
  bridge/bridge.go:229:6: S1002: should omit comparison to bool constant, can be simplified to `!b.config.Internal` (gosimple)
  		if b.config.Internal != true && port.HostPort == "" {
  bridge/bridge.go:301:5: S1002: should omit comparison to bool constant, can be simplified to `b.config.Internal` (gosimple)
  	if b.config.Internal == true {
  bridge/bridge.go:213:41: composites: github.com/fsouza/go-dockerclient.PortBinding struct literal uses unkeyed fields (govet)
  		published := []dockerapi.PortBinding{ {"0.0.0.0", port.Port()}, }
  • Loading branch information
fho committed Oct 22, 2024
1 parent ebdeefa commit d502d0c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (b *Bridge) add(containerId string, quiet bool) {

// Extract configured host port mappings, relevant when using --net=host
for port := range container.Config.ExposedPorts {
published := []dockerapi.PortBinding{{"0.0.0.0", port.Port()}}
published := []dockerapi.PortBinding{{HostIP: "0.0.0.0", HostPort: port.Port()}}
ports[string(port)] = servicePort(container, port, published)
}

Expand All @@ -226,7 +226,7 @@ func (b *Bridge) add(containerId string, quiet bool) {

servicePorts := make(map[string]ServicePort)
for key, port := range ports {
if b.config.Internal != true && port.HostPort == "" {
if !b.config.Internal && port.HostPort == "" {
if !quiet {
log.Println("ignored:", container.ID[:12], "port", port.ExposedPort, "not published on host")
}
Expand Down Expand Up @@ -298,7 +298,7 @@ func (b *Bridge) newService(port ServicePort, isgroup bool) *Service {
}
var p int

if b.config.Internal == true {
if b.config.Internal {
service.IP = port.ExposedIP
p, _ = strconv.Atoi(port.ExposedPort)
} else {
Expand Down
6 changes: 3 additions & 3 deletions etcd/etcd.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package etcd

import (
"io/ioutil"
"io"
"log"
"net"
"net/http"
Expand Down Expand Up @@ -34,9 +34,9 @@ func (f *Factory) New(uri *url.URL) bridge.RegistryAdapter {
}

defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
body, _ := io.ReadAll(res.Body)

if match, _ := regexp.Match("0\\.4\\.*", body); match == true {
if match, _ := regexp.Match("0\\.4\\.*", body); match {
log.Println("etcd: using v0 client")
return &EtcdAdapter{client: etcd.NewClient(urls), path: uri.Path}
}
Expand Down
2 changes: 1 addition & 1 deletion zookeeper/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (f *Factory) New(uri *url.URL) bridge.RegistryAdapter {
log.Println("zookeeper: error checking if base path exists:", err)
}
if !exists {
c.Create(uri.Path, []byte{}, 0, zk.WorldACL(zk.PermAll))
c.Create(uri.Path, []byte{}, 0, zk.WorldACL(zk.PermAll)) // nolint:errcheck
}
return &ZkAdapter{client: c, path: uri.Path}
}
Expand Down

0 comments on commit d502d0c

Please sign in to comment.