Skip to content

Commit 99efa68

Browse files
authored
Merge pull request #89 from bottlerocket-os/quote-raw-output
quote raw command output in errors
2 parents 79d3a13 + 017ee5f commit 99efa68

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

updater/aws.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (u *updater) filterAvailableUpdates(bottlerocketInstances []instance) ([]in
133133
output, err := parseCommandOutput(commandOutput)
134134
if err != nil {
135135
// not a fatal error, we can continue checking other instances.
136-
log.Printf("Failed to parse command output %s: %v", string(commandOutput), err)
136+
log.Printf("Failed to parse command output %q: %v", string(commandOutput), err)
137137
continue
138138
}
139139
if output.UpdateState == updateStateAvailable || output.UpdateState == updateStateReady {
@@ -268,7 +268,7 @@ func (u *updater) updateInstance(inst instance) error {
268268
}
269269
check, err := parseCommandOutput(output)
270270
if err != nil {
271-
return fmt.Errorf("failed to parse command output %s: %w", string(output), err)
271+
return fmt.Errorf("failed to parse command output %q: %w", string(output), err)
272272
}
273273

274274
switch check.UpdateState {
@@ -331,7 +331,7 @@ func (u *updater) verifyUpdate(inst instance) (bool, error) {
331331
}
332332
output, err := parseCommandOutput(updateResult)
333333
if err != nil {
334-
return false, fmt.Errorf("failed to parse command output %s, manual verification required: %w", string(updateResult), err)
334+
return false, fmt.Errorf("failed to parse command output %q, manual verification required: %w", string(updateResult), err)
335335
}
336336
updatedVersion := output.ActivePartition.Image.Version
337337
if updatedVersion == inst.bottlerocketVersion {

updater/aws_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ func TestVerifyUpdateErr(t *testing.T) {
952952
bottlerocketVersion: "0.0.0",
953953
})
954954
require.Error(t, err)
955-
assert.Contains(t, err.Error(), "failed to parse command output , manual verification required")
955+
assert.Contains(t, err.Error(), `failed to parse command output "", manual verification required`)
956956
assert.False(t, ok)
957957
})
958958
}

0 commit comments

Comments
 (0)