Add plugin create functionality. - #28164
Conversation
|
cc @vieux @tiborvass |
There was a problem hiding this comment.
There is no description about rootfs in docs/extend/manifest.md. Can you add it?
There was a problem hiding this comment.
uh, I found that in docs/extend/index.md
There was a problem hiding this comment.
I'll do it in #28148 if it ever get's merged. it's good like this for now
|
How about using an image instead of a raw rootfs directory? e.g. |
|
@AkihiroSuda we discussed this already, we think it's a good idea, it's coming soon (in a separate PR) |
6ecf061 to
d7591e6
Compare
There was a problem hiding this comment.
@anusha-ragunathan won't this be logged twice ? once here and once in the calling function ?
d7591e6 to
5c4ed5d
Compare
|
LGTM ping @tiborvass |
There was a problem hiding this comment.
why isn't this returning a simple error ?
There was a problem hiding this comment.
return err should be enough
|
Apart from small optional nit, LGTM |
5c4ed5d to
3df961a
Compare
|
ping @thaJeztah |
|
LGTM |
There was a problem hiding this comment.
Since this is an example, the header should be part of the example;
POST /plugins/plugin:latest/create HTTP/1.1
Content-Type: application/tar
{% raw %}
{{ TAR STREAM }}
{% endraw %}
Also can you check if application/tar or application/x-tar is the correct header? We use x-tar in other endpoints; https://github.com/docker/docker/blob/master/docs/reference/api/docker_remote_api_v1.25.md#extract-an-archive-of-files-or-folders-to-a-directory-in-a-container
According to http://superuser.com/a/960710, there's still no official content-type for tar
There was a problem hiding this comment.
application/tar is indeed not registered at http://www.iana.org/assignments/media-types/media-types.xhtml#application. Unregistered mime types are considered "experimental" and have an x- prefix. So it makes sense to replace with application/x-tar.
Ofcourse curl recognizes both types. Eg. curl -H "Content-Type: application/tar" -X POST http://localhost:9999/v1.25/plugins/testplugin/create --data-binary "@/tmp/pluginDir/context.tar"
There was a problem hiding this comment.
Yes, they probably work both. If it doesn't make a difference to us, then I prefer x-tar to be consistent
There was a problem hiding this comment.
This line can probably be removed if the example is updated
There was a problem hiding this comment.
this should be "plugin create (experimental)"
in the new docs rendering, this is actually used to create the H1 heading
There was a problem hiding this comment.
The page title should be removed for the new docs system (it's generated from the metadata)
There was a problem hiding this comment.
Fixed. The last 3 comments apply across all plugin md files. @thaJeztah, is there a tool to run to check if the md files confirm to the new format? I ask because there might be a lot more across docker/docker.
There was a problem hiding this comment.
for the new docs, the [ and ] should be removed
There was a problem hiding this comment.
should this be POST /plugins/create?name=<plugin name> instead? Feels odd to have an endpoint named after a not-yet existing resource.
/cc @bfirsh
There was a problem hiding this comment.
@thaJeztah : that's what we have for other plugin endpoints such as enable, disable, push and set as well. I can either fix it just for create here, or make a follow-up PR to fix them all.
There was a problem hiding this comment.
@anusha-ragunathan it's fine for enable disable, it's an action on an existing resource. (container start and stop are the same)
but I see @thaJeztah's point, it's different for create, the resource doesn't yet exist. (same for image or container create, it's not in the URL)
There was a problem hiding this comment.
👍 Standard REST for creating an object is POST /objects. The reasoning, I think:
- You are performing an action against the resource that is the set of plugins. The resource
/plugins/namedoes not exist yet. - Servers often generate an ID or name for you. (Not the case in this instance, but may as well be consistent.)
- Consistency. All REST APIs do this, so you kinda expect this to work.
Also worth noting that the endpoint is almost always POST /objects, not POST /objects/create, even though lots of our API does the latter. Depends whether you want to be consistent with the current world or a potential better future world! See also #25015.
There was a problem hiding this comment.
@thaJeztah : I went ahead and updated endpoint to plugin/create/name=<>, after being convinced about the non-existent object endpoint.
There was a problem hiding this comment.
It should probably be /plugins/create?name=foo, as in with name as a GET parameter. To follow the reasoning in (1) above, that's performing an action against the resource /plugins/create, but with name as an additional option.
It would typically be in the request body, but in this case that's impossible.
(I would also argue this should be just POST /plugins, but I'm happy to fix this in one big go in #25015. ;)
There was a problem hiding this comment.
@bfirsh: +1 for tidying up all APIs URLs in one shot :)
|
Any chance you could also update |
3df961a to
5466e29
Compare
185bfd2 to
7945c69
Compare
|
@bfirsh @thaJeztah : Updated with review comments on API. PTAL |
There was a problem hiding this comment.
Perhaps use the same as for image build;
- **name** - A name and optional tag to apply for the plugin in the `name:tag format`.
If you omit the `tag` the default `:latest` value is assumed.There was a problem hiding this comment.
same review showing up thrice. fast fingers ? :)
bfirsh
left a comment
There was a problem hiding this comment.
Nice, thanks! Looks like it was the old format, though – I've commented the fixes. :)
thaJeztah
left a comment
There was a problem hiding this comment.
one nit/suggestion, but LGTM otherwise
There was a problem hiding this comment.
oh, hold on: this should be prefixed with /v1.25 now
2978dac to
0828a01
Compare
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
0828a01 to
5b6e1bc
Compare
|
@bfirsh @thaJeztah : updated |
|
swagger.yaml LGTM! |
|
Do not merge until #27967 is merged moving back to docs review to prevent trigger-happy's |
Add plugin create functionality.
Add plugin create functionality.
- What I did
Add
plugin createfunctionality.- How I did it
Given a rootfs and a plugin manifest.json, create a plugin.
- How to verify it
Use
docker plugin createto create the plugin. Once successfully create, you can enable it and use it. You can alsodocker plugin pushto registry.Signed-off-by: Anusha Ragunathan anusha@docker.com