Merge lp:~jtv/gwacl/bug-1213059 into lp:gwacl

Proposed by Jeroen T. Vermeulen on 2013-08-19
Status: Merged
Approved by: Jeroen T. Vermeulen on 2013-08-19
Approved revision: 224
Merged at revision: 220
Proposed branch: lp:~jtv/gwacl/bug-1213059
Merge into: lp:gwacl
Diff against target: 65 lines (+14/-6)
1 file modified
example/storage/run.go (+14/-6)
To merge this branch: bzr merge lp:~jtv/gwacl/bug-1213059
Reviewer Review Type Date Requested Status
Julian Edwards (community) 2013-08-19 Approve on 2013-08-19
Review via email: mp+180782@code.launchpad.net

Commit message

Add, and use, -location option in storage example/tool.

Description of the change

The -location option is mandatory, because it selects the API endpoint that the program will make its requests to in the first place. (In practice there only seem to be two zones: mainland China and the rest of the world. A storage account in one won't necessarily exist in the other, although a storage account in one location will also be available for other locations in the same zone.)

I also corrected a silly mistake in my previous branch: the "list" operation listed "list" as one of its required arguments. That should have been "container".

Jeroen

To post a comment you must log in.
Julian Edwards (julian-edwards) wrote :

Perhaps only insist on location for things that need it?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'example/storage/run.go'
--- example/storage/run.go 2013-08-19 05:20:08 +0000
+++ example/storage/run.go 2013-08-19 06:09:09 +0000
@@ -55,7 +55,7 @@
55 name: "list",55 name: "list",
56 description: "List files in a container",56 description: "List files in a container",
57 example: "-container=<container> list",57 example: "-container=<container> list",
58 requiredArgs: []string{"list"},58 requiredArgs: []string{"container"},
59 implementation: list,59 implementation: list,
60 },60 },
61 {61 {
@@ -65,7 +65,8 @@
65 requiredArgs: []string{"container", "key", "acl"},65 requiredArgs: []string{"container", "key", "acl"},
66 validate: func() error {66 validate: func() error {
67 if acl != "container" && acl != "blob" && acl != "private" {67 if acl != "container" && acl != "blob" && acl != "private" {
68 return fmt.Errorf("Usage: containeracl -container=<container> <container|blob|private>")68 return fmt.Errorf(
69 "Usage: containeracl -container=<container> <container|blob|private>")
69 }70 }
70 return nil71 return nil
71 },72 },
@@ -154,6 +155,8 @@
154 switch name {155 switch name {
155 case "account":156 case "account":
156 return account != ""157 return account != ""
158 case "location":
159 return location != ""
157 case "key":160 case "key":
158 return key != ""161 return key != ""
159 case "container":162 case "container":
@@ -180,6 +183,7 @@
180 flag.BoolVar(&help, "h", false, "Show usage and exit")183 flag.BoolVar(&help, "h", false, "Show usage and exit")
181184
182 flag.StringVar(&account, "account", "", "Storage account name")185 flag.StringVar(&account, "account", "", "Storage account name")
186 flag.StringVar(&location, "location", "", "Azure location, e.g. \"West US\", \"China East\", or \"North Europe\"")
183 flag.StringVar(&key, "key", "", "A valid storage account key (base64 encoded), defaults to the empty string (i.e. anonymous access)")187 flag.StringVar(&key, "key", "", "A valid storage account key (base64 encoded), defaults to the empty string (i.e. anonymous access)")
184 flag.StringVar(&container, "container", "", "Name of the container to use")188 flag.StringVar(&container, "container", "", "Name of the container to use")
185 flag.StringVar(&filename, "filename", "", "File containing blob/page to upload/download")189 flag.StringVar(&filename, "filename", "", "File containing blob/page to upload/download")
@@ -200,8 +204,11 @@
200 return "", fmt.Errorf("No operation specified")204 return "", fmt.Errorf("No operation specified")
201 }205 }
202206
203 if account == "" {207 requiredArgs := []string{"account", "location"}
204 return "", fmt.Errorf("Must supply account parameter")208 for _, arg := range requiredArgs {
209 if !argumentGiven(arg) {
210 return "", fmt.Errorf("Must supply %q parameter.", arg)
211 }
205 }212 }
206213
207 if len(flag.Args()) != 1 {214 if len(flag.Args()) != 1 {
@@ -379,8 +386,9 @@
379 }386 }
380387
381 storage := gwacl.StorageContext{388 storage := gwacl.StorageContext{
382 Account: account,389 Account: account,
383 Key: key,390 Key: key,
391 AzureEndpoint: gwacl.GetEndpoint(location),
384 }392 }
385393
386 perform := operationsByName[op].implementation394 perform := operationsByName[op].implementation

Subscribers

People subscribed via source and target branches