From 65d63dbed77b23986a91692647af6002f4253d21 Mon Sep 17 00:00:00 2001 From: Christopher Boumenot Date: Wed, 27 Sep 2017 00:09:40 -0700 Subject: [PATCH] address upgrade issues --- promote.go | 7 ++----- publish.go | 17 ++++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/promote.go b/promote.go index 9f3dd4d..eec5a17 100644 --- a/promote.go +++ b/promote.go @@ -45,9 +45,6 @@ func promoteExtension(c *cli.Context, factory func() (extensionManifest, error)) return err } - if err := publishExtension(c, "UpdateExtension", b, - mkClient(checkFlag(c, flMgtURL.Name), checkFlag(c, flSubsID.Name), checkFlag(c, flSubsCert.Name)).UpdateExtension); err != nil { - return err - } - return nil + return publishExtension(c, "UpdateExtension", b, + mkClient(checkFlag(c, flMgtURL.Name), checkFlag(c, flSubsID.Name), checkFlag(c, flSubsCert.Name)).UpdateExtension) } diff --git a/publish.go b/publish.go index 8f0651a..6d35848 100644 --- a/publish.go +++ b/publish.go @@ -97,10 +97,6 @@ func uploadBlob(cl ExtensionsClient, storageRealm, storageAccount, packagePath s if err != nil { return "", fmt.Errorf("Could not reach package file: %v", err) } - stat, err := pkg.Stat() - if err != nil { - return "", fmt.Errorf("Could not stat the package file: %v", err) - } defer pkg.Close() // Upload blob @@ -108,13 +104,20 @@ func uploadBlob(cl ExtensionsClient, storageRealm, storageAccount, packagePath s if err != nil { return "", fmt.Errorf("Could not create storage client: %v", err) } + bs := sc.GetBlobService() - if _, err := bs.CreateContainerIfNotExists(containerName, storage.ContainerAccessTypeBlob); err != nil { + container := bs.GetContainerReference(containerName) + opts := storage.CreateContainerOptions{ + Access: storage.ContainerAccessTypeBlob, + } + + if _, err := container.CreateIfNotExists(&opts); err != nil { return "", fmt.Errorf("Error creating blob container: %v", err) } blobName := fmt.Sprintf("%d.zip", time.Now().Unix()) - if err := bs.CreateBlockBlobFromReader(containerName, blobName, uint64(stat.Size()), pkg, nil); err != nil { + blob := container.GetBlobReference(blobName) + if err := blob.CreateBlockBlobFromReader(pkg, &storage.PutBlobOptions{}); err != nil { return "", fmt.Errorf("Error uploading blob: %v", err) } - return bs.GetBlobURL(containerName, blobName), nil + return blob.GetURL(), nil }