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

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
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) Approve
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.
Revision history for this message
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
1=== modified file 'example/storage/run.go'
2--- example/storage/run.go 2013-08-19 05:20:08 +0000
3+++ example/storage/run.go 2013-08-19 06:09:09 +0000
4@@ -55,7 +55,7 @@
5 name: "list",
6 description: "List files in a container",
7 example: "-container=<container> list",
8- requiredArgs: []string{"list"},
9+ requiredArgs: []string{"container"},
10 implementation: list,
11 },
12 {
13@@ -65,7 +65,8 @@
14 requiredArgs: []string{"container", "key", "acl"},
15 validate: func() error {
16 if acl != "container" && acl != "blob" && acl != "private" {
17- return fmt.Errorf("Usage: containeracl -container=<container> <container|blob|private>")
18+ return fmt.Errorf(
19+ "Usage: containeracl -container=<container> <container|blob|private>")
20 }
21 return nil
22 },
23@@ -154,6 +155,8 @@
24 switch name {
25 case "account":
26 return account != ""
27+ case "location":
28+ return location != ""
29 case "key":
30 return key != ""
31 case "container":
32@@ -180,6 +183,7 @@
33 flag.BoolVar(&help, "h", false, "Show usage and exit")
34
35 flag.StringVar(&account, "account", "", "Storage account name")
36+ flag.StringVar(&location, "location", "", "Azure location, e.g. \"West US\", \"China East\", or \"North Europe\"")
37 flag.StringVar(&key, "key", "", "A valid storage account key (base64 encoded), defaults to the empty string (i.e. anonymous access)")
38 flag.StringVar(&container, "container", "", "Name of the container to use")
39 flag.StringVar(&filename, "filename", "", "File containing blob/page to upload/download")
40@@ -200,8 +204,11 @@
41 return "", fmt.Errorf("No operation specified")
42 }
43
44- if account == "" {
45- return "", fmt.Errorf("Must supply account parameter")
46+ requiredArgs := []string{"account", "location"}
47+ for _, arg := range requiredArgs {
48+ if !argumentGiven(arg) {
49+ return "", fmt.Errorf("Must supply %q parameter.", arg)
50+ }
51 }
52
53 if len(flag.Args()) != 1 {
54@@ -379,8 +386,9 @@
55 }
56
57 storage := gwacl.StorageContext{
58- Account: account,
59- Key: key,
60+ Account: account,
61+ Key: key,
62+ AzureEndpoint: gwacl.GetEndpoint(location),
63 }
64
65 perform := operationsByName[op].implementation

Subscribers

People subscribed via source and target branches