upload/azure: force .vhd extension
Azure cannot create an image from a storage blob without .vhd extension. This commit ensures that image always has the right extension.
This commit is contained in:
parent
1d52dfcc2b
commit
6513263a14
1 changed files with 6 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"io"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/Azure/azure-storage-blob-go/azblob"
|
||||
|
|
@ -34,6 +35,11 @@ type ImageMetadata struct {
|
|||
// It can speed up the upload by using goroutines. The number of parallel goroutines is bounded by
|
||||
// the `threads` argument.
|
||||
func UploadImage(credentials Credentials, metadata ImageMetadata, fileName string, threads int) error {
|
||||
// Azure cannot create an image from a storage blob without .vhd extension
|
||||
if !strings.HasSuffix(metadata.ImageName, ".vhd") {
|
||||
metadata.ImageName = metadata.ImageName + ".vhd"
|
||||
}
|
||||
|
||||
// Create a default request pipeline using your storage account name and account key.
|
||||
credential, err := azblob.NewSharedKeyCredential(credentials.StorageAccount, credentials.StorageAccessKey)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue