Skip to content

Commit 5144ac2

Browse files
authored
Merge pull request #7 from ahmetalpbalkan/pr-storage-realm
Allow sovereign clouds to upload the extension pkg
2 parents 42a13c7 + f308b71 commit 5144ac2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66

77
"github.com/Azure/azure-sdk-for-go/management"
8+
"github.com/Azure/azure-sdk-for-go/storage"
89
log "github.com/Sirupsen/logrus"
910
"github.com/codegangsta/cli"
1011
)
@@ -32,6 +33,11 @@ var (
3233
Usage: "Azure Management URL for a non-public Azure cloud",
3334
Value: management.DefaultAzureManagementURL,
3435
EnvVar: "MANAGEMENT_URL"}
36+
flStorageRealm = cli.StringFlag{
37+
Name: "storage-base-url",
38+
Usage: "Azure Storage base URL",
39+
Value: storage.DefaultBaseURL,
40+
EnvVar: "STORAGE_BASE_URL"}
3541
flSubsID = cli.StringFlag{
3642
Name: "subscription-id",
3743
Usage: "Subscription ID for the publisher subscription",
@@ -79,8 +85,8 @@ func main() {
7985
Usage: "Creates an XML file used to publish or update extension.",
8086
Action: newExtensionManifest,
8187
Flags: []cli.Flag{
82-
flMgtURL, flSubsID, flSubsCert, flPackage, flStorageAccount,
83-
flNamespace, flName, flVersion,
88+
flMgtURL, flSubsID, flSubsCert, flPackage, flStorageRealm,
89+
flStorageAccount, flNamespace, flName, flVersion,
8490
cli.StringFlag{
8591
Name: "label",
8692
Usage: "Human readable name of the extension"},

manifest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
func newExtensionManifest(c *cli.Context) {
1212
cl := mkClient(checkFlag(c, flMgtURL.Name), checkFlag(c, flSubsID.Name), checkFlag(c, flSubsCert.Name))
13+
storageRealm := checkFlag(c, flStorageRealm.Name)
1314
storageAccount := checkFlag(c, flStorageAccount.Name)
1415
extensionPkg := checkFlag(c, flPackage.Name)
1516

@@ -36,7 +37,7 @@ func newExtensionManifest(c *cli.Context) {
3637
}
3738

3839
// Upload extension blob
39-
blobURL, err := uploadBlob(cl, storageAccount, extensionPkg)
40+
blobURL, err := uploadBlob(cl, storageRealm, storageAccount, extensionPkg)
4041
if err != nil {
4142
log.Fatal(err)
4243
}

publish.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func updateExtension(c *cli.Context) {
8383
}
8484
}
8585

86-
func uploadBlob(cl ExtensionsClient, storageAccount, packagePath string) (string, error) {
86+
func uploadBlob(cl ExtensionsClient, storageRealm, storageAccount, packagePath string) (string, error) {
8787
// Fetch keys for storage account
8888
svc := storageservice.NewClient(cl.client)
8989
keys, err := svc.GetStorageServiceKeys(storageAccount)
@@ -104,7 +104,7 @@ func uploadBlob(cl ExtensionsClient, storageAccount, packagePath string) (string
104104
defer pkg.Close()
105105

106106
// Upload blob
107-
sc, err := storage.NewBasicClient(storageAccount, keys.PrimaryKey)
107+
sc, err := storage.NewClient(storageAccount, keys.PrimaryKey, storageRealm, storage.DefaultAPIVersion, true)
108108
if err != nil {
109109
return "", fmt.Errorf("Could not create storage client: %v", err)
110110
}

0 commit comments

Comments
 (0)