From 1945b458f5b0f3f7dc4018917f31748106247abc Mon Sep 17 00:00:00 2001 From: Paul Mars Date: Tue, 19 Sep 2023 17:20:56 +0200 Subject: [PATCH] Fix last linter issues --- internal/statemachine/classic_states.go | 1 + internal/statemachine/helper.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/statemachine/classic_states.go b/internal/statemachine/classic_states.go index 14119e3b..afaca88d 100644 --- a/internal/statemachine/classic_states.go +++ b/internal/statemachine/classic_states.go @@ -1194,6 +1194,7 @@ func (stateMachine *StateMachine) preseedClassicImage() error { // assemble the commands in the correct order: mount, preseed, unmount preseedCmds = append(preseedCmds, mountCmds...) preseedCmds = append(preseedCmds, + //nolint:gosec,G204 exec.Command("/usr/lib/snapd/snap-preseed", stateMachine.tempDirs.chroot), ) preseedCmds = append(preseedCmds, umountCmds...) diff --git a/internal/statemachine/helper.go b/internal/statemachine/helper.go index b40b7762..648b9370 100644 --- a/internal/statemachine/helper.go +++ b/internal/statemachine/helper.go @@ -1079,7 +1079,15 @@ func (stateMachine *StateMachine) updateGrub(rootfsVolName string, rootfsPartNum "--detach", loopUsed, ) - defer teardownCmd.Run() + defer func() { + if tmpErr := teardownCmd.Run(); tmpErr != nil { + if err != nil { + err = fmt.Errorf("%s after previous error: %w", tmpErr, err) + } else { + err = tmpErr + } + } + }() updateGrubCmds = append(updateGrubCmds, teardownCmd) // now run all the commands