-
-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arrays within query parameters #91
Comments
@twifty arrays aren't being querystringify'd properly due to /cc @apocas |
Interesting, will check this one. |
I can't replicated this, there's even a test for this. https://github.com/apocas/docker-modem/blob/master/test/modem_test.js#L109 INPUT: var opts = {
"limit": 12,
"filters": {
"label": ["staging", "env=green"]
},
"t": ["repo:latest", "repo:1.0.0"]
}; OUTPUT: The array "t" was properly converted. |
Missed that. Can't remember why that was done. Will check if removing the stringify doesn't break anything. |
Passes: https://github.com/apocas/dockerode/blob/master/test/docker.js#L648 So we can't just remove the stringify. Add that parameter as an exception? |
@apocas looks like it was introduced with this commit: 8565c3f. Regarding my use case, as far as I remember it was related to passing an array of environment variables when creating/starting (not sure) a Docker container using dockerode. It was not working and debug'd down to this part of the code in docker-modem. |
But we can't just remove this condition because the are endpoints expecting the data "stringifed". Like https://github.com/apocas/dockerode/blob/master/test/docker.js#L658 On the other hand there are parameters that are expected by Docker to be repeated like "t" in imageBuild. https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild If "extrahosts" is one of this cases we can add it to the exception list, like "t". |
@apocas I tried to get multiple images, I need to pass names as array to query, but it doesn't work. |
Same here, i was working with the getImages function from dockerode and i discovered the query string is not created as expected.
gets changed to
in the cloned object and the querystring created by it it's incorrect. Happy to help if you want!! |
The API states that some of the query parameters can be duplicated. for example the 'extrahosts' and 't' parameters of ImageBuild.
I see this library makes use of
querystrings
, and correctly converts objects to JSON strings. But, it doesn't handle arrays. So, for example, given an object like:querystrings
will covert to 'extrahosts[0]=somehost:162.242.195.82&extrahosts[1]=otherhost:50.31.209.229' (escaped of course).docker-py
uses therequests
package which simply repeats the name and is consistent with the API docs: 'extrahosts=somehost:162.242.195.82&extrahosts=otherhost:50.31.209.229' .While the array notation may work on some systems, it all depends on the binary the daemon uses. It may very well break on some OS's or daemon versions.
The text was updated successfully, but these errors were encountered: