mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #21274 from jfrazelle/fix-variables-that-werent-being-used
fix variables that werent being called
This commit is contained in:
commit
b77573f48e
15 changed files with 40 additions and 34 deletions
|
@ -103,8 +103,6 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
|
||||||
stderr = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
|
stderr = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
|
||||||
stdout = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
|
stdout = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
outStream = w
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now run the user process in container.
|
// Now run the user process in container.
|
||||||
|
|
|
@ -142,6 +142,9 @@ func sanitizeRepoAndTags(names []string) ([]reference.Named, error) {
|
||||||
|
|
||||||
if _, isTagged := ref.(reference.NamedTagged); !isTagged {
|
if _, isTagged := ref.(reference.NamedTagged); !isTagged {
|
||||||
ref, err = reference.WithTag(ref, reference.DefaultTag)
|
ref, err = reference.WithTag(ref, reference.DefaultTag)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nameWithTag := ref.String()
|
nameWithTag := ref.String()
|
||||||
|
|
|
@ -136,7 +136,7 @@ func Parse(rwc io.Reader) (*Node, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if child == nil && line != "" {
|
if child == nil && line != "" {
|
||||||
line, child, err = parseLine(line)
|
_, child, err = parseLine(line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -378,12 +378,14 @@ func TestJsonWithPsFormat(t *testing.T) {
|
||||||
|
|
||||||
// Save it and make sure it shows up in new form
|
// Save it and make sure it shows up in new form
|
||||||
func saveConfigAndValidateNewFormat(t *testing.T, config *ConfigFile, homeFolder string) string {
|
func saveConfigAndValidateNewFormat(t *testing.T, config *ConfigFile, homeFolder string) string {
|
||||||
err := config.Save()
|
if err := config.Save(); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Failed to save: %q", err)
|
t.Fatalf("Failed to save: %q", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := ioutil.ReadFile(filepath.Join(homeFolder, ConfigFileName))
|
buf, err := ioutil.ReadFile(filepath.Join(homeFolder, ConfigFileName))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
if !strings.Contains(string(buf), `"auths":`) {
|
if !strings.Contains(string(buf), `"auths":`) {
|
||||||
t.Fatalf("Should have save in new form: %s", string(buf))
|
t.Fatalf("Should have save in new form: %s", string(buf))
|
||||||
}
|
}
|
||||||
|
@ -487,6 +489,9 @@ func TestJsonSaveWithNoFile(t *testing.T) {
|
||||||
t.Fatalf("Failed saving to file: %q", err)
|
t.Fatalf("Failed saving to file: %q", err)
|
||||||
}
|
}
|
||||||
buf, err := ioutil.ReadFile(filepath.Join(tmpHome, ConfigFileName))
|
buf, err := ioutil.ReadFile(filepath.Join(tmpHome, ConfigFileName))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
expConfStr := `{
|
expConfStr := `{
|
||||||
"auths": {
|
"auths": {
|
||||||
"https://index.docker.io/v1/": {
|
"https://index.docker.io/v1/": {
|
||||||
|
@ -517,11 +522,13 @@ func TestLegacyJsonSaveWithNoFile(t *testing.T) {
|
||||||
|
|
||||||
fn := filepath.Join(tmpHome, ConfigFileName)
|
fn := filepath.Join(tmpHome, ConfigFileName)
|
||||||
f, _ := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
f, _ := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
err = config.SaveToWriter(f)
|
if err = config.SaveToWriter(f); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Failed saving to file: %q", err)
|
t.Fatalf("Failed saving to file: %q", err)
|
||||||
}
|
}
|
||||||
buf, err := ioutil.ReadFile(filepath.Join(tmpHome, ConfigFileName))
|
buf, err := ioutil.ReadFile(filepath.Join(tmpHome, ConfigFileName))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
expConfStr := `{
|
expConfStr := `{
|
||||||
"auths": {
|
"auths": {
|
||||||
|
|
|
@ -883,7 +883,6 @@ func parseRemappedRoot(usergrp string) (string, string, error) {
|
||||||
}
|
}
|
||||||
return "", "", fmt.Errorf("Error during %q user creation: %v", defaultRemappedID, err)
|
return "", "", fmt.Errorf("Error during %q user creation: %v", defaultRemappedID, err)
|
||||||
}
|
}
|
||||||
userID = luser.Uid
|
|
||||||
username = luser.Name
|
username = luser.Name
|
||||||
if len(idparts) == 1 {
|
if len(idparts) == 1 {
|
||||||
// we only have a string username, and no group specified; look up gid from username as group
|
// we only have a string username, and no group specified; look up gid from username as group
|
||||||
|
@ -909,11 +908,9 @@ func parseRemappedRoot(usergrp string) (string, string, error) {
|
||||||
groupname = lgrp.Name
|
groupname = lgrp.Name
|
||||||
} else {
|
} else {
|
||||||
// not a number; attempt a lookup
|
// not a number; attempt a lookup
|
||||||
group, err := user.LookupGroup(idparts[1])
|
if _, err := user.LookupGroup(idparts[1]); err != nil {
|
||||||
if err != nil {
|
return "", "", fmt.Errorf("Error during groupname lookup for %q: %v", idparts[1], err)
|
||||||
return "", "", fmt.Errorf("Error during gid lookup for %q: %v", idparts[1], err)
|
|
||||||
}
|
}
|
||||||
groupID = group.Gid
|
|
||||||
groupname = idparts[1]
|
groupname = idparts[1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,6 +371,10 @@ func (d *Driver) Get(id string, mountLabel string) (string, error) {
|
||||||
// chown "workdir/work" to the remapped root UID/GID. Overlay fs inside a
|
// chown "workdir/work" to the remapped root UID/GID. Overlay fs inside a
|
||||||
// user namespace requires this to move a directory from lower to upper.
|
// user namespace requires this to move a directory from lower to upper.
|
||||||
rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps)
|
rootUID, rootGID, err := idtools.GetRootUIDGID(d.uidMaps, d.gidMaps)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
if err := os.Chown(path.Join(workDir, "work"), rootUID, rootGID); err != nil {
|
if err := os.Chown(path.Join(workDir, "work"), rootUID, rootGID); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ func (t *authZPluginTestServer) start() {
|
||||||
r.HandleFunc("/Plugin.Activate", t.activate)
|
r.HandleFunc("/Plugin.Activate", t.activate)
|
||||||
r.HandleFunc("/"+AuthZApiRequest, t.auth)
|
r.HandleFunc("/"+AuthZApiRequest, t.auth)
|
||||||
r.HandleFunc("/"+AuthZApiResponse, t.auth)
|
r.HandleFunc("/"+AuthZApiResponse, t.auth)
|
||||||
t.listener, err = net.Listen("tcp", pluginAddress)
|
t.listener, _ = net.Listen("tcp", pluginAddress)
|
||||||
server := http.Server{Handler: r, Addr: pluginAddress}
|
server := http.Server{Handler: r, Addr: pluginAddress}
|
||||||
server.Serve(l)
|
server.Serve(l)
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,6 +168,9 @@ func TestMoveToSubdir(t *testing.T) {
|
||||||
}
|
}
|
||||||
// validate that the files were moved to the subdirectory
|
// validate that the files were moved to the subdirectory
|
||||||
infos, err := ioutil.ReadDir(subDir)
|
infos, err := ioutil.ReadDir(subDir)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
if len(infos) != 4 {
|
if len(infos) != 4 {
|
||||||
t.Fatalf("Should be four files in the subdir after the migration: actual length: %d", len(infos))
|
t.Fatalf("Should be four files in the subdir after the migration: actual length: %d", len(infos))
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,10 @@ package directory
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/longpath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Size walks a directory tree and returns its total size in bytes.
|
// Size walks a directory tree and returns its total size in bytes.
|
||||||
func Size(dir string) (size int64, err error) {
|
func Size(dir string) (size int64, err error) {
|
||||||
fixedPath, err := filepath.Abs(dir)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fixedPath = longpath.AddPrefix(fixedPath)
|
|
||||||
err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error {
|
err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error {
|
||||||
// Ignore directory sizes
|
// Ignore directory sizes
|
||||||
if fileInfo == nil {
|
if fileInfo == nil {
|
||||||
|
|
|
@ -93,7 +93,7 @@ func (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error {
|
||||||
ffjsonWriteJSONString(buf, mj.Log)
|
ffjsonWriteJSONString(buf, mj.Log)
|
||||||
}
|
}
|
||||||
if len(mj.Stream) != 0 {
|
if len(mj.Stream) != 0 {
|
||||||
if first == true {
|
if first {
|
||||||
first = false
|
first = false
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(`,`)
|
buf.WriteString(`,`)
|
||||||
|
@ -101,9 +101,7 @@ func (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error {
|
||||||
buf.WriteString(`"stream":`)
|
buf.WriteString(`"stream":`)
|
||||||
ffjsonWriteJSONString(buf, mj.Stream)
|
ffjsonWriteJSONString(buf, mj.Stream)
|
||||||
}
|
}
|
||||||
if first == true {
|
if !first {
|
||||||
first = false
|
|
||||||
} else {
|
|
||||||
buf.WriteString(`,`)
|
buf.WriteString(`,`)
|
||||||
}
|
}
|
||||||
buf.WriteString(`"time":`)
|
buf.WriteString(`"time":`)
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error {
|
||||||
ffjsonWriteJSONString(buf, mj.Stream)
|
ffjsonWriteJSONString(buf, mj.Stream)
|
||||||
}
|
}
|
||||||
if len(mj.RawAttrs) > 0 {
|
if len(mj.RawAttrs) > 0 {
|
||||||
if first == true {
|
if first {
|
||||||
first = false
|
first = false
|
||||||
} else {
|
} else {
|
||||||
buf.WriteString(`,`)
|
buf.WriteString(`,`)
|
||||||
|
@ -47,9 +47,7 @@ func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error {
|
||||||
buf.WriteString(`"attrs":`)
|
buf.WriteString(`"attrs":`)
|
||||||
buf.Write(mj.RawAttrs)
|
buf.Write(mj.RawAttrs)
|
||||||
}
|
}
|
||||||
if first == true {
|
if !first {
|
||||||
first = false
|
|
||||||
} else {
|
|
||||||
buf.WriteString(`,`)
|
buf.WriteString(`,`)
|
||||||
}
|
}
|
||||||
buf.WriteString(`"time":`)
|
buf.WriteString(`"time":`)
|
||||||
|
|
|
@ -61,8 +61,7 @@ func ensureMountedAs(mountPoint, options string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mounted, err = Mounted(mountPoint)
|
if _, err = Mounted(mountPoint); err != nil {
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,8 +112,7 @@ func TestBufioWriterPoolPutAndGet(t *testing.T) {
|
||||||
buf.Reset()
|
buf.Reset()
|
||||||
BufioWriter32KPool.Put(writer)
|
BufioWriter32KPool.Put(writer)
|
||||||
// Try to write something
|
// Try to write something
|
||||||
written, err = writer.Write([]byte("barfoo"))
|
if _, err = writer.Write([]byte("barfoo")); err != nil {
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
// If we now try to flush it, it should panic (the writer is nil)
|
// If we now try to flush it, it should panic (the writer is nil)
|
||||||
|
|
|
@ -23,8 +23,7 @@ func toShort(path string) (string, error) {
|
||||||
}
|
}
|
||||||
if n > uint32(len(b)) {
|
if n > uint32(len(b)) {
|
||||||
b = make([]uint16, n)
|
b = make([]uint16, n)
|
||||||
n, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b)))
|
if _, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))); err != nil {
|
||||||
if err != nil {
|
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -560,6 +560,10 @@ func Benchmark9kTar(b *testing.B) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n, err := io.Copy(buf, fh)
|
n, err := io.Copy(buf, fh)
|
||||||
|
if err != nil {
|
||||||
|
b.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
fh.Close()
|
fh.Close()
|
||||||
|
|
||||||
reader := bytes.NewReader(buf.Bytes())
|
reader := bytes.NewReader(buf.Bytes())
|
||||||
|
@ -586,6 +590,10 @@ func Benchmark9kTarGzip(b *testing.B) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
n, err := io.Copy(buf, fh)
|
n, err := io.Copy(buf, fh)
|
||||||
|
if err != nil {
|
||||||
|
b.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
fh.Close()
|
fh.Close()
|
||||||
|
|
||||||
reader := bytes.NewReader(buf.Bytes())
|
reader := bytes.NewReader(buf.Bytes())
|
||||||
|
|
Loading…
Reference in a new issue