azure: move the .vhd extension logic to the callers

It always felt wrong that the method uploaded the blob under a different name
than the one specified in the blob metadata.

This commit moves the responsibility of specifying the right extension to
the callers. azure.EnsureVHDExtension helper was added to simplify this.

Signed-off-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Ondřej Budai 2022-05-11 20:00:27 +02:00 committed by Ondřej Budai
parent 9e6ade2eff
commit f71ca8f0ca
4 changed files with 37 additions and 11 deletions

View file

@ -43,10 +43,12 @@ func main() {
os.Exit(1)
}
blobName := azure.EnsureVHDExtension(path.Base(fileName))
err = c.UploadPageBlob(
azure.BlobMetadata{
StorageAccount: storageAccount,
BlobName: path.Base(fileName),
BlobName: blobName,
ContainerName: containerName,
},
fileName,