azure: return an early error if unaligned
If the image size isn't aligned to 512 bytes, the Azure API returns very hard to understand error message. Let's do this check ourselves early so we can return a sane error. Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
parent
3ed3f2ed95
commit
f67ca8b616
1 changed files with 4 additions and 0 deletions
|
|
@ -71,6 +71,10 @@ func UploadImage(credentials Credentials, metadata ImageMetadata, fileName strin
|
|||
return fmt.Errorf("cannot stat the image: %v", err)
|
||||
}
|
||||
|
||||
if stat.Size()%512 != 0 {
|
||||
return errors.New("size for azure image must be aligned to 512 bytes")
|
||||
}
|
||||
|
||||
// Hash the imageFile
|
||||
imageFileHash := md5.New()
|
||||
if _, err := io.Copy(imageFileHash, imageFile); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue