fix: error early when the image write fails (#34)

Closes #33
This commit is contained in:
Julian Tölle 2024-06-23 16:13:52 +02:00 committed by GitHub
parent 8347e4ef16
commit 256989f4a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -299,6 +299,10 @@ func (s *Client) Upload(ctx context.Context, options UploadOptions) (*hcloud.Ima
}
cmd += "dd of=/dev/sda bs=4M && sync"
// Make sure that we fail early, ie. if the image url does not work.
// the pipefail does not work correctly without wrapping in bash.
cmd = fmt.Sprintf("bash -c 'set -euo pipefail && %s'", cmd)
logger.DebugContext(ctx, "running download, decompress and write to disk command", "cmd", cmd)
output, err := sshsession.Run(sshClient, cmd, options.ImageReader)