Merge lp:~julian-edwards/gwacl/container-acl into lp:gwacl
Proposed by
Julian Edwards
Status: | Merged |
---|---|
Approved by: | Julian Edwards |
Approved revision: | 139 |
Merged at revision: | 132 |
Proposed branch: | lp:~julian-edwards/gwacl/container-acl |
Merge into: | lp:gwacl |
Prerequisite: | lp:~julian-edwards/gwacl/extra-putpage-checks |
Diff against target: |
210 lines (+141/-1) 3 files modified
example/storage/run.go (+24/-1) storage_base.go (+38/-0) storage_base_test.go (+79/-0) |
To merge this branch: | bzr merge lp:~julian-edwards/gwacl/container-acl |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+171016@code.launchpad.net |
Commit message
Add API call for SetContainerACL.
Description of the change
This adds the SetContainerACL call where you can set a container's ACL. This ACL has three options (unless you dive into shared access keys, which we don't do here):
1. private
2. container - allows full read-only access to all aspects of the container
3. blob - allows people to retrieve known blobs from a container, nothing else including no container listing
I buggered up my new branch and branched off my previous one instead of trunk, so I stuck it as a prerequisite to make the diff correct. Ignore it here.
To post a comment you must log in.
I see we have "*Request" and "*Params" types now. Doesn't it get a bit verbose, what with all the long camel-cased names?
.
In example/ storage/ run.go:
case "containeracl":
fmt.Printf( "***:%s\ n", acl)
—did you intend to remove this before submitting? Or if not, it could be clearer.
.
if container == "" {
return "", fmt.Errorf("Must supply container with containeracl")
}
if acl != "container" && acl != "blob" && acl != "private" { <container> <container| blob|private> ")
return "", fmt.Errorf("Usage: containeracl -container=
}
—this would be so easy in Python: you'd just use the same single list of possibilities for the check and the error message. Go adds more overhead, pushing you towards a "switch" as the clearest expression.
But given that the "<container| blob|private> " choice keeps coming back, isn't it worth folding all this into a single data structure?
.
In SetContainerACL:
switch req.Access {
extraHeaders. Add("x- ms-blob- public- access" , req.Access)
panic( "Access must be one of 'container', 'blob' or 'private'")
case "container", "blob":
case "private":
// Don't add a header, Azure resets to private if it's omitted.
default:
}
Is the special treatment of "private" really pulling its weight here? If it's at all reasonable to extraHeaders. Add("x- ms-blob- public- access" , "private") then I'd just do that unconditionally, and reduce this switch to just one line. It'd also save you some testing.
.
In TestInvalidAcce ssTypePanics, for testing the contents of the error, you probably want the ErrorMatches checker rather than Equals — since the panic is probably an error implementation, not a string as such. Assuming that it compares to a string may be a bit brittle. ErrorMatches takes a regex for the error text.
.
ISTR seeing some non-aligned initializer elements in there. Fine by me, but it may mean that you ought to re-run the formatter. Save somebody else the spurious diff.
.
And that's it! My compliments on the thorough testing.