Automatic API generation via go-restful#2282
Conversation
There was a problem hiding this comment.
Flexibility, no other reason.
There was a problem hiding this comment.
Took away that flexibility for now. We can add it back later if needed.
|
Will rebase and squash once #2222 is merged. |
|
Rebase is now pushed. PTAL. |
There was a problem hiding this comment.
You can condense the above with .Infof("InstallREST: %v kinds: %#v", version, kinds)
|
missing gofmt. I'd like to give this another look-through before it's merged, I'm still digesting that gigantic function... |
|
Feedback addressed. |
|
Same here - promise to look in morning.
|
|
verify-gofmt and e2e pass in my sandbox. Not sure what's up with Travis. |
There was a problem hiding this comment.
It looks like Consume takes as many mime types as you want. So maybe enumerate the ones we take rather than accept all?
Now, the question is what mime type(s) YAML is.
I think ws.Consumes(restful.MIME_JSON, "application/x-yaml", "text/yaml") should do it
There was a problem hiding this comment.
Yes, Consume takes an arbitrary number of types. However, not all clients set a content type at all, and there is no standard yaml type. I figure this can be fixed in a follow-up PR, after we get our client library and tools squared away.
|
Didn't do a super detailed review, but looks good overall. You can git rid of the whoami handler if it is causing you trouble. I haven't needed it like I thought I would. |
|
Thanks @erictune. I know there's lots more to do, but I'm just trying to get in the minimal viable change before other PRs break it again. It will be easier to iterate on it once it's merged. |
|
Could I be running a different version of gofmt than Travis? Travis complains: I ran gofmt on these 2 files and pushed them because verify-gofmt complained on my system. However, how Travis complains about them. gofmt doesn't have a and to the second: |
|
Did you forget that you have to stage files again after running gofmt? On Wed, Nov 12, 2014 at 10:05 PM, bgrant0607 notifications@github.com
|
|
I have no unpushed changes. If you look at the commit history, it's the pushes of gofmt changes that caused the Travis failures. |
|
For the container_info_test.go, try introducing a newline above and below For apiserver.go, you pasted the wrong thing in your mail, but maybe the On Wed, Nov 12, 2014 at 10:17 PM, bgrant0607 notifications@github.com
|
There was a problem hiding this comment.
But if they're unversioned we can't evolve them without introducing new fields and deprecating old ones. I'm somewhat scared about introducing these until we have a good idea what they should be doing, because we can't change them in a version compatible way. Do you have confidence these are the right objects?
There was a problem hiding this comment.
We already return APIVersions. This just moves it.
APIResources could be versioned, I suppose.
There was a problem hiding this comment.
Commented out APIResources and added TODOs for now.
There was a problem hiding this comment.
Having to do this seems to defeat the purpose of taking apiserver.Mux.
|
I did have an incompatible version of gofmt in my path. Now using the gofmt from go 1.3. |
|
Travis is green. All feedback addressed. |
|
just want to throw in my +1 |
|
Can you update your commit message to not be WIP and remove the error? Seems like it's busted |
|
gofmt: it did change at some point; I forget what version we standardized on. It follows your go version. I have version 1.3. |
There was a problem hiding this comment.
From a readability standpoint, I think it would be great if the body of this loop were moved into its own function, e.g., installSingleHandler or some such. I'm ok merging without this if it will get cleaned up soon, although I'm feeling like in general promised cleanup has not been happening at the promised rate and I'm getting reluctant to say things like this...
There was a problem hiding this comment.
Maybe we need a cleanup week.
On Nov 13, 2014, at 3:48 PM, Daniel Smith notifications@github.com wrote:
In pkg/apiserver/apiserver.go:
- // create one for the tests, also
- // Success:
- // http.StatusOK, http.StatusCreated, http.StatusAccepted, http.StatusNoContent
- //
- // test/integration/auth_test.go is currently the most comprehensive status code test
- // TODO: eliminate all the restful wrappers
- // TODO: create a separate handler per verb
- h := func(req *restful.Request, resp *restful.Response) {
glog.V(3).Infof("User-Agent: %s\n", req.HeaderParameter("User-Agent"))strippedHandler.ServeHTTP(resp.ResponseWriter, req.Request)- }
- // TODO: factor out per-kind code
- for path, storage := range g.handler.storage {
From a readability standpoint, I think it would be great if the body of this loop were moved into its own function, e.g., installSingleHandler or some such. I'm ok merging without this if it will get cleaned up soon, although I'm feeling like in general promised cleanup has not been happening at the promised rate and I'm getting reluctant to say things like this...glog.V(3).Infof("Installing /%s/%s\n", version, path)—
Reply to this email directly or view it on GitHub.
There was a problem hiding this comment.
I'll refactor it now, esp. since it won't be merged until tomorrow, anyway.
|
LGTM with responses to my last two comments. |
|
Feedback addressed, but now I'm having a really weird gofmt issue. I get a gofmt error that prevents me from rebasing, even though I've removed the old gofmt binary and even if I specify --no-verify AND remove the prepare-commit-msg hooks. Sigh. |
|
Learned enough git to make the rebase work, and reinstalled go on my system for good measure. Ok to merge now? |
|
About to merge, rerunning travis in case a fluke occured. |
|
@smarterclayton Travis is green both on head and on this PR. Did you see a failure earlier? |
|
LGTM, thanks for rearranging. |
Automatic API generation via go-restful
|
I'm in the habit of rebuilding Travis right before big refactor merges now because Travis won't rebuild if someone else delivers function. Bit me a few times.
|
…-disabled-older-kubelet-ocp-master OCPBUGS-55632: Fix node expansion on older kubelets
Partially addresses #1052.
There's lots more work left to do here, but I got this working, so I thought I'd share it.
go-restful provides a more structured handler registration mechanism, with the ability to document a number of aspects of the API. The object definitions are extracted via reflection and their descriptions are extracted from field tags (added by the author of go-restful upon my request). It uses https://github.com/swagger-api/swagger-ui for the doc UI, and also provides a discovery API that can be used to query available endpoints and json schemas.
In order for the initial version of this to be merged, two main things need to be done:
Beyond that, I'd like to iterate on cleaning this up and adding documentation in other PRs:
/cc @lavalamp @smarterclayton @erictune