GitHub PushEvent at 2014-09-24 08:39:19
Repository: gophercloud
Actor: jamiehannaford
Payload: {"shas":[["a9b147cbd6be27c58777dbd447022fb4a7578a67","7dff39b3dea7b28db2566fa7cafd5c512cb27e18@arrl.net","Merge pull request #3 from rackspace/script-environment-setup\n\nScript to automate environment creation","Samuel A. Falvo II",false],["d6092adfb69759791c3f3fdd99e5642066e3e642","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Add script to launch acceptance tests","Samuel A. Falvo II",false],["1d3fa667c76ec6dabb67a0b13ce07c3022768f4c","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Add authentication acceptance test.\n\nBefore coding on the Authentication functionality of gophercloud, we\nneeded the acceptance test to know when we were finished.\n\nSince the authentication test is written in Go, I had to adjust the\nscripts/test-all.sh file to invoke Go programs directly.","Samuel A. Falvo II",false],["fd78c30473c2f64b2c0ef3263b0f1e1f963c36a8","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Add provider registry support.","Samuel A. Falvo II",false],["5d0d74ce130097c44e1c6290a607c74ec58a59ee","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Make Authenticate issue an HTTP request","Samuel A. Falvo II",false],["978fed843429bf8a6e3c20c0f28e5f58eb2cfc09","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Verify proper Tenant ID encoding behavior","Samuel A. Falvo II",false],["00a233d1e1a75d630ee886000642f41de4c969e2","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","code cleanup","Samuel A. Falvo II",false],["839428e0c2bc7006b922bfec7f1fdb04c4c749e6","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","go fmt","Samuel A. Falvo II",false],["d1ee7987fd4c036272d39d80bc3b89b6d22a518c","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Parse out auth response and fill in access object","Samuel A. Falvo II",false],["4e89518cd94761fba4f9449d02530d1317f53681","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Add global Authenticate() function.\n\nAlso finishes work started in last commit.","Samuel A. Falvo II",false],["43fa244bacff5277b68739b3c50586110196532c","7dff39b3dea7b28db2566fa7cafd5c512cb27e18@arrl.net","Merge pull request #9 from rackspace/authentication\n\nAdd Authentication functionality.\r\n\r\nNow that I have the time to write this up, here's the description that should have gone into the git commit message.\r\n\r\ngophercloud needs to authenticate against a provider. However, gorax's API isn't ideal from a multi-provider perspective. Thus, instead of requiring the user to instantiate Identity objects, configuring them, and then authenticating in a 3-step process, I create a single public function, Authenticate(), which performs (essentially) these tasks.\r\n\r\nI cannot predict the future, and cannot guarantee Identity V3 compatibility in its current form. However, in an attempt to anticipate the future, the Authenticate function is designed to automatically guess which Identity API you intend on using based on which set of credentials you provide it. The underlying assumption is that a V3 token is compatible with a V2 token; once we have the token, it should be usable with other V2 and V3 APIs as appropriate.\r\n\r\nUnlike Ruby or Python, Go lacks support for keyword arguments. There are two ways to overcome this deficiency: (1) Make a function that accepts one or more interface{} types, and rely on type-checks to disambiguate meaning from supplied parameters; and, (2) use a structure and rely upon Go's automatic initialization of unspecified fields to well-known \"zero\" values. Here's a comparison of the two approaches from the point of view of the caller:\r\n\r\n// option 1 -- use list of interface{} types\r\nacc, err := gophercloud.Authenticate(\"rackspace-us\", gophercloud.Username(\"sfalvo\"), gophercloud.Password(\"my-pass-here\"), gophercloud.TenantId(\"blah\"))\r\n\r\n// option 2 -- use of a dedicated options structure\r\naccRackspace, err := gophercloud.Authenticate(\"rackspace-us\", gophercloud.AuthOptions{\r\n    Username: \"sfalvo\",\r\n    Password: \"my-pass-here\",\r\n    TenantId: \"blah\",\r\n})\r\nAs can be seen, the latter requires much less physical typing (assuming one doesn't rename the gophercloud package to just 'g' in the import statement), and thus less chance for error. That's why I decided to use an options structure instead. It also impacts the design of the callee as well; with option (1), I'd have to manually loop through all the parameters, using a type-case statement to decode the supplied parameters and fill in variables as they're discovered, while in (2) I just inspect the options structure directly. Less code means fewer bugs.\r\n\r\nSince the method of authentication remains the same across all providers, assuming universal use of V2 APIs, I associate an AuthEndpoint field with each Provider instance. That's the only per-provider piece of information defined at the moment.\r\n\r\nMost other SDKs hard-wire their providers; however, this is grossly inconvenient for unit-testing purposes. Therefore, I wrap what would otherwise be global state into a Context structure. TestContext exists to create a blank context, which can be used by unit tests at will. You'll notice that the init() function (in the api.go file) uses it to create the one, true, global context, and pre-populates it with the otherwise statically defined list of providers. Through this mechanism, users of the library needn't concern themselves with contexts and their proper initialization. Instead, they can just use the package-global functions, and they should \"just work.\"\r\n\r\nNote that the result of Authenticate() is a structure instance, allowing the client access to the service catalog, tenant ID information, and user information. As we flesh out additional APIs for the Go SDK, we will add methods to this Access structure, allowing more convenient access to various APIs. For example, one hypothetical approach to working with Cloud Compute services would involve using Access as a factory:\r\n\r\ncompute, err := accRackspace.CloudComputeApi()\r\nThis conforms to the first two levels of the desired <organization.service.entity.method> SDK organization, and provides the appropriate propegation of state that allows for token re-auth in a fully transparent manner, if necessary.","Samuel A. Falvo II",false],["07552815c87658057cfee56cfae9e50a9cfee889","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Update README.md with typo fixes and Getting Started","Samuel A. Falvo II",false],["7b830c970d2a1011093f95a0a1f6df39fa2b9cd0","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Translate from markdown to asciidoc","Samuel A. Falvo II",false],["841204d289c81f16426cc7ba4727d85924c5fe98","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Change filename to match new format","Samuel A. Falvo II",false],["4c11721051d516cf999666f30bfc7837ce4990d4","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Fix accidental code block syntax","Samuel A. Falvo II",false],["b4abb058ae399858dce42154dac40edd45ef75ac","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Compensate for lack of gh support for admonitions","Samuel A. Falvo II",false],["9566bf8689231b467af3652679ab52e38b28edc7","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Replace table with callouts","Samuel A. Falvo II",false],["56e961f1257c11057ebc6c507d89922efdc39924","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Add link to gophercloud-dev, fix admonition","Samuel A. Falvo II",false],["fc2cdefed8f8dba336222c17f2ad651269176d92","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Fix admonition again","Samuel A. Falvo II",false],["1a28751ec60e4019b5d1129fe8d6ce88c939c795","68d0aed27d1dfc541dc86f3524d04757be89f3bc@rackspace.com","Remove typo","Samuel A. Falvo II",false]],"size":468,"ref":"refs/heads/os-network-v2","head":"d903642c1e975bae5e0b545f6087569e5cd1e73a"}