diff --git a/api/server/server.go b/api/server/server.go index 1cce7060a4..3874a56ce5 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -126,7 +126,11 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc) http.HandlerFunc { // apply to all requests. Data that is specific to the // immediate function being called should still be passed // as 'args' on the function call. - ctx := context.WithValue(context.Background(), dockerversion.UAStringKey, r.Header.Get("User-Agent")) + + // use intermediate variable to prevent "should not use basic type + // string as key in context.WithValue" golint errors + var ki interface{} = dockerversion.UAStringKey + ctx := context.WithValue(context.Background(), ki, r.Header.Get("User-Agent")) handlerFunc := s.handlerWithGlobalMiddlewares(handler) vars := mux.Vars(r) diff --git a/builder/fscache/fscache.go b/builder/fscache/fscache.go index e80f3d5bce..92c3ea4adb 100644 --- a/builder/fscache/fscache.go +++ b/builder/fscache/fscache.go @@ -615,7 +615,7 @@ func (s sortableCacheSources) Swap(i, j int) { } func newTarsumHash(stat *fsutil.Stat) (hash.Hash, error) { - fi := &fsutil.StatInfo{stat} + fi := &fsutil.StatInfo{Stat: stat} p := stat.Path if fi.IsDir() { p += string(os.PathSeparator) diff --git a/client/swarm_unlock_test.go b/client/swarm_unlock_test.go index 93d5d69815..b3bcc5d922 100644 --- a/client/swarm_unlock_test.go +++ b/client/swarm_unlock_test.go @@ -17,7 +17,7 @@ func TestSwarmUnlockError(t *testing.T) { client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")), } - err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{"SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"}) + err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{UnlockKey: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"}) if err == nil || err.Error() != "Error response from daemon: Server error" { t.Fatalf("expected a Server Error, got %v", err) } @@ -41,7 +41,7 @@ func TestSwarmUnlock(t *testing.T) { }), } - err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{"SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"}) + err := client.SwarmUnlock(context.Background(), swarm.UnlockRequest{UnlockKey: "SWMKEY-1-y6guTZNTwpQeTL5RhUfOsdBdXoQjiB2GADHSRJvbXeU"}) if err != nil { t.Fatal(err) } diff --git a/cmd/dockerd/daemon_unix.go b/cmd/dockerd/daemon_unix.go index 6ab2ada485..af16fa4e1b 100644 --- a/cmd/dockerd/daemon_unix.go +++ b/cmd/dockerd/daemon_unix.go @@ -107,10 +107,10 @@ func allocateDaemonPort(addr string) error { func wrapListeners(proto string, ls []net.Listener) []net.Listener { switch proto { case "unix": - ls[0] = &hack.MalformedHostHeaderOverride{ls[0]} + ls[0] = &hack.MalformedHostHeaderOverride{Listener: ls[0]} case "fd": for i := range ls { - ls[i] = &hack.MalformedHostHeaderOverride{ls[i]} + ls[i] = &hack.MalformedHostHeaderOverride{Listener: ls[i]} } } return ls diff --git a/daemon/graphdriver/overlay/overlay.go b/daemon/graphdriver/overlay/overlay.go index 6932e4df81..62dc26a871 100644 --- a/daemon/graphdriver/overlay/overlay.go +++ b/daemon/graphdriver/overlay/overlay.go @@ -168,7 +168,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, err } // Create the driver home dir - if err := idtools.MkdirAllAndChown(home, 0700, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAllAndChown(home, 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, err } @@ -410,7 +410,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, err erro if err != nil { return nil, err } - if err := idtools.MkdirAndChown(mergedDir, 0700, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAndChown(mergedDir, 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, err } var ( diff --git a/daemon/graphdriver/overlay2/overlay.go b/daemon/graphdriver/overlay2/overlay.go index 39b9a8b389..2b52adb858 100644 --- a/daemon/graphdriver/overlay2/overlay.go +++ b/daemon/graphdriver/overlay2/overlay.go @@ -200,7 +200,7 @@ func Init(home string, options []string, uidMaps, gidMaps []idtools.IDMap) (grap return nil, err } // Create the driver home dir - if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAllAndChown(path.Join(home, linkDir), 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, err } @@ -581,7 +581,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e if err != nil { return nil, err } - if err := idtools.MkdirAndChown(mergedDir, 0700, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAndChown(mergedDir, 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, err } diff --git a/daemon/graphdriver/zfs/zfs.go b/daemon/graphdriver/zfs/zfs.go index 39d606fb9f..eeceb4d3b8 100644 --- a/daemon/graphdriver/zfs/zfs.go +++ b/daemon/graphdriver/zfs/zfs.go @@ -106,7 +106,7 @@ func Init(base string, opt []string, uidMaps, gidMaps []idtools.IDMap) (graphdri if err != nil { return nil, fmt.Errorf("Failed to get root uid/guid: %v", err) } - if err := idtools.MkdirAllAndChown(base, 0700, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAllAndChown(base, 0700, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, fmt.Errorf("Failed to create '%s': %v", base, err) } @@ -385,7 +385,7 @@ func (d *Driver) Get(id, mountLabel string) (_ containerfs.ContainerFS, retErr e return nil, err } // Create the target directories if they don't exist - if err := idtools.MkdirAllAndChown(mountpoint, 0755, idtools.IDPair{rootUID, rootGID}); err != nil { + if err := idtools.MkdirAllAndChown(mountpoint, 0755, idtools.IDPair{UID: rootUID, GID: rootGID}); err != nil { return nil, err } diff --git a/daemon/volumes_windows.go b/daemon/volumes_windows.go index 3d63d02e1c..a2fb5152d1 100644 --- a/daemon/volumes_windows.go +++ b/daemon/volumes_windows.go @@ -24,7 +24,7 @@ func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, er if err := daemon.lazyInitializeVolume(c.ID, mount); err != nil { return nil, err } - s, err := mount.Setup(c.MountLabel, idtools.IDPair{0, 0}, nil) + s, err := mount.Setup(c.MountLabel, idtools.IDPair{UID: 0, GID: 0}, nil) if err != nil { return nil, err } diff --git a/integration/service/network_test.go b/integration/service/network_test.go index 09f663b323..d69aeb91f6 100644 --- a/integration/service/network_test.go +++ b/integration/service/network_test.go @@ -29,7 +29,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { cID1 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) { c.NetworkingConfig = &network.NetworkingConfig{ - map[string]*network.EndpointSettings{ + EndpointsConfig: map[string]*network.EndpointSettings{ name: {}, }, } @@ -52,7 +52,7 @@ func TestDockerNetworkConnectAlias(t *testing.T) { cID2 := container.Create(t, ctx, client, func(c *container.TestContainerConfig) { c.NetworkingConfig = &network.NetworkingConfig{ - map[string]*network.EndpointSettings{ + EndpointsConfig: map[string]*network.EndpointSettings{ name: {}, }, } diff --git a/libcontainerd/client_daemon_linux.go b/libcontainerd/client_daemon_linux.go index 53349def38..a2237dc9f5 100644 --- a/libcontainerd/client_daemon_linux.go +++ b/libcontainerd/client_daemon_linux.go @@ -58,7 +58,7 @@ func getSpecUser(ociSpec *specs.Spec) (int, int) { func prepareBundleDir(bundleDir string, ociSpec *specs.Spec) (string, error) { uid, gid := getSpecUser(ociSpec) if uid == 0 && gid == 0 { - return bundleDir, idtools.MkdirAllAndChownNew(bundleDir, 0755, idtools.IDPair{0, 0}) + return bundleDir, idtools.MkdirAllAndChownNew(bundleDir, 0755, idtools.IDPair{UID: 0, GID: 0}) } p := string(filepath.Separator) @@ -71,7 +71,7 @@ func prepareBundleDir(bundleDir string, ociSpec *specs.Spec) (string, error) { } if os.IsNotExist(err) || fi.Mode()&1 == 0 { p = fmt.Sprintf("%s.%d.%d", p, uid, gid) - if err := idtools.MkdirAndChown(p, 0700, idtools.IDPair{uid, gid}); err != nil && !os.IsExist(err) { + if err := idtools.MkdirAndChown(p, 0700, idtools.IDPair{UID: uid, GID: gid}); err != nil && !os.IsExist(err) { return "", err } } diff --git a/pkg/archive/archive_windows.go b/pkg/archive/archive_windows.go index e75bfc9b62..69aadd823c 100644 --- a/pkg/archive/archive_windows.go +++ b/pkg/archive/archive_windows.go @@ -73,5 +73,5 @@ func handleLChmod(hdr *tar.Header, path string, hdrInfo os.FileInfo) error { func getFileUIDGID(stat interface{}) (idtools.IDPair, error) { // no notion of file ownership mapping yet on Windows - return idtools.IDPair{0, 0}, nil + return idtools.IDPair{UID: 0, GID: 0}, nil } diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go index 4988f74244..25297d077f 100644 --- a/plugin/manager_linux.go +++ b/plugin/manager_linux.go @@ -53,7 +53,7 @@ func (pm *Manager) enable(p *v2.Plugin, c *controller, force bool) error { } rootFS := containerfs.NewLocalContainerFS(filepath.Join(pm.config.Root, p.PluginObj.ID, rootFSFileName)) - if err := initlayer.Setup(rootFS, idtools.IDPair{0, 0}); err != nil { + if err := initlayer.Setup(rootFS, idtools.IDPair{UID: 0, GID: 0}); err != nil { return errors.WithStack(err) }