Show executed command when errors occurred (#1252)
This commit is contained in:
		
							parent
							
								
									1e9e228a9a
								
							
						
					
					
						commit
						23be9af2db
					
				|  | @ -2,13 +2,12 @@ package helmexec | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"path/filepath" |  | ||||||
| 	"strings" | 	"strings" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func newExitError(helmCmdPath string, exitStatus int, errorMessage string) ExitError { | func newExitError(helmCmdPath string, exitStatus int, errorMessage string) ExitError { | ||||||
| 	return ExitError{ | 	return ExitError{ | ||||||
| 		Message: fmt.Sprintf("%s exited with status %d:\n%s", filepath.Base(helmCmdPath), exitStatus, indent(strings.TrimSpace(errorMessage))), | 		Message: fmt.Sprintf("the following cmd exited with status %d:\n%s\n\n%s", exitStatus, indent(strings.TrimSpace(helmCmdPath)), indent(strings.TrimSpace(errorMessage))), | ||||||
| 		Code:    exitStatus, | 		Code:    exitStatus, | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -64,7 +64,8 @@ func combinedOutput(c *exec.Cmd, logger *zap.SugaredLogger) ([]byte, error) { | ||||||
| 			// so that helmfile could return its own exit code accordingly
 | 			// so that helmfile could return its own exit code accordingly
 | ||||||
| 			waitStatus := ee.Sys().(syscall.WaitStatus) | 			waitStatus := ee.Sys().(syscall.WaitStatus) | ||||||
| 			exitStatus := waitStatus.ExitStatus() | 			exitStatus := waitStatus.ExitStatus() | ||||||
| 			err = newExitError(c.Path, exitStatus, string(e)) | 			cmd := fmt.Sprintf("%s %s", c.Path, strings.Join(c.Args, " ")) | ||||||
|  | 			err = newExitError(cmd, exitStatus, string(e)) | ||||||
| 		default: | 		default: | ||||||
| 			panic(fmt.Sprintf("unexpected error: %v", err)) | 			panic(fmt.Sprintf("unexpected error: %v", err)) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue