mirror of
				https://github.com/moby/moby.git
				synced 2022-11-09 12:21:53 -05:00 
			
		
		
		
	Merge pull request #17715 from cpuguy83/17708_fix_inspect_output_on_error
Reutrn immediately when inspect connection failed
This commit is contained in:
		
						commit
						1eafc7264c
					
				
					 1 changed files with 15 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -61,14 +61,19 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 | 
			
		|||
	for _, name := range cmd.Args() {
 | 
			
		||||
		if *inspectType == "" || *inspectType == "container" {
 | 
			
		||||
			obj, _, err = readBody(cli.call("GET", "/containers/"+name+"/json?"+v.Encode(), nil, nil))
 | 
			
		||||
			if err != nil && *inspectType == "container" {
 | 
			
		||||
				if strings.Contains(err.Error(), "No such") {
 | 
			
		||||
					fmt.Fprintf(cli.err, "Error: No such container: %s\n", name)
 | 
			
		||||
				} else {
 | 
			
		||||
					fmt.Fprintf(cli.err, "%s", err)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				if err == errConnectionFailed {
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
				if *inspectType == "container" {
 | 
			
		||||
					if strings.Contains(err.Error(), "No such") {
 | 
			
		||||
						fmt.Fprintf(cli.err, "Error: No such container: %s\n", name)
 | 
			
		||||
					} else {
 | 
			
		||||
						fmt.Fprintf(cli.err, "%s", err)
 | 
			
		||||
					}
 | 
			
		||||
					status = 1
 | 
			
		||||
					continue
 | 
			
		||||
				}
 | 
			
		||||
				status = 1
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -76,6 +81,9 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 | 
			
		|||
			obj, _, err = readBody(cli.call("GET", "/images/"+name+"/json", nil, nil))
 | 
			
		||||
			isImage = true
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				if err == errConnectionFailed {
 | 
			
		||||
					return err
 | 
			
		||||
				}
 | 
			
		||||
				if strings.Contains(err.Error(), "No such") {
 | 
			
		||||
					if *inspectType == "" {
 | 
			
		||||
						fmt.Fprintf(cli.err, "Error: No such image or container: %s\n", name)
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +96,6 @@ func (cli *DockerCli) CmdInspect(args ...string) error {
 | 
			
		|||
				status = 1
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if tmpl == nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue