@@ -93,7 +93,7 @@ func includeFlag(flag, val string) []string {
9393// Notice:
9494// ----------------------------------------------------
9595// Zero values (0, "", nil, false) and "-" will be ignored
96- func StructToCLI (optionStruct interface {}) []string { // nolint: gocyclo
96+ func StructToCLI (optionStruct interface {}) []string {
9797 if optionStruct == reflect .Zero (reflect .TypeOf (optionStruct )).Interface () {
9898 return nil
9999 }
@@ -201,12 +201,12 @@ func Run(ctx context.Context, cmd CommandType) ([]byte, error) {
201201 commandLine := ParseCommandLine (cmd )
202202 log .WithField ("command" , strings .Join (commandLine , " " )).Debug ("executing command" )
203203 if ctx != nil {
204- out , err = exec .CommandContext (ctx , commandLine [0 ], commandLine [1 :]... ).CombinedOutput ()
204+ out , err = exec .CommandContext (ctx , commandLine [0 ], commandLine [1 :]... ).CombinedOutput () // nolint: gosec
205205 if ctx .Err () != nil {
206206 return out , fmt .Errorf ("failed to execute command: timed out or canceled" )
207207 }
208208 } else {
209- out , err = exec .Command (commandLine [0 ], commandLine [1 :]... ).CombinedOutput ()
209+ out , err = exec .Command (commandLine [0 ], commandLine [1 :]... ).CombinedOutput () // nolint: gosec
210210 }
211211 if err != nil {
212212 return out , fmt .Errorf ("failed to execute command: %s" , err )
@@ -251,13 +251,8 @@ func RunPiped(ctx context.Context, cmd1, cmd2 CommandType, pids *PipedCommandsPi
251251 ),
252252 ).Debug ("executing command" )
253253
254- if ctx != nil {
255- cmd1Exec = exec .CommandContext (ctx , cmdLine1 [0 ], cmdLine1 [1 :]... )
256- cmd2Exec = exec .CommandContext (ctx , cmdLine2 [0 ], cmdLine2 [1 :]... )
257- } else {
258- cmd1Exec = exec .Command (cmdLine1 [0 ], cmdLine1 [1 :]... )
259- cmd2Exec = exec .Command (cmdLine2 [0 ], cmdLine2 [1 :]... )
260- }
254+ cmd1Exec = exec .CommandContext (ctx , cmdLine1 [0 ], cmdLine1 [1 :]... ) // nolint: gosec
255+ cmd2Exec = exec .CommandContext (ctx , cmdLine2 [0 ], cmdLine2 [1 :]... ) // nolint: gosec
261256
262257 cmd2Exec .Stdin , err = cmd1Exec .StdoutPipe ()
263258 if err != nil {
@@ -288,7 +283,8 @@ func RunPiped(ctx context.Context, cmd1, cmd2 CommandType, pids *PipedCommandsPi
288283
289284 err = cmd1Exec .Wait ()
290285 if err != nil {
291- msg , ok := err .(* exec.ExitError )
286+ var msg exec.ExitError
287+ ok := errors .As (err , & msg )
292288 if ! ok || ! (cmd1 .Binary == "tar" && msg .Sys ().(syscall.WaitStatus ).ExitStatus () == 1 ) { // ignore tar exit-code of 1
293289 errs = append (errs , err .Error ())
294290 }
@@ -438,7 +434,7 @@ func CheckAndGunzipFile(fileName string) (string, error) {
438434 }()
439435
440436 // write unzipped file to file system
441- _ , err = io .Copy (outFile , archiveReader )
437+ _ , err = io .Copy (outFile , archiveReader ) // nolint: gosec // we work with potentially large backups
442438 if err != nil {
443439 return "" , errors .WithStack (err )
444440 }
0 commit comments