marpaia / chef-golang

Go library to interact with the Chef server API
Other
77 stars 32 forks source link

No way to pass different host to the base http methods #28

Open spheromak opened 10 years ago

spheromak commented 10 years ago

This is sorta related to the uniformity discussion of GET/POST/PUT in #22 Today i wrote a lil cookbook downloader, and the inflexability of chef.Get was brought to light. even with the proposed changes to allow params etc. The fact that we always connect to the same host is a bad assumption.

When you get a chef.CookbookVersion from the server it has urls to the bookshelf in the respons. The bookshelf does not have to be the same as the chef-server. We will need to be able to send signed requests to arbitrary servers to support download/upload of objects.

My thoughts on this right now are to just make those base methods expect an http.Request, and just sign and ship it. Then add in the methods to each type (cookbook,role etc) Upload and Download methods. This shouldn't effect the public api so much as well. I just want to put it out what I am thinking.

/cc @marpaia @ctdk @fujin

spheromak commented 10 years ago

see https://gist.github.com/spheromak/c3c93eafd1129bca231b for some code to talk against.

spheromak commented 10 years ago

this call to con.Get at https://gist.github.com/spheromak/c3c93eafd1129bca231b#file-client_download-go-L28 Will always goto whatever host is part of the config, and not part of whats been returned to the client in https://gist.github.com/spheromak/c3c93eafd1129bca231b#file-client_download-go-L28 which is the Item.Url (from the cookbookVersion struct)

spheromak commented 10 years ago

Perhaps what Is in order is making chef.makeRequest a public method. This method takes a raw request and will sign and submit it returning the response. This is probably the 'right' way to do it.

Means the GET/POST etc methods can remain implementing just what we need, but maybe have some docs on the caveats.

Alternatively I am ok with removing chef.Get Post etc and just calling MakeRequest with an assembled request obj.