mirror of https://github.com/docker/cli.git
Add plugin create functionality.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
parent
58c2d938dd
commit
3d7a95829e
|
@ -1,6 +1,8 @@
|
||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"io"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
@ -27,4 +29,5 @@ type PluginAPIClient interface {
|
||||||
PluginPush(ctx context.Context, name string, registryAuth string) error
|
PluginPush(ctx context.Context, name string, registryAuth string) error
|
||||||
PluginSet(ctx context.Context, name string, args []string) error
|
PluginSet(ctx context.Context, name string, args []string) error
|
||||||
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
|
PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error)
|
||||||
|
PluginCreate(ctx context.Context, createContext io.Reader, options types.PluginCreateOptions) error
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package client
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types"
|
||||||
|
"golang.org/x/net/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PluginCreate creates a plugin
|
||||||
|
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
|
||||||
|
headers := http.Header(make(map[string][]string))
|
||||||
|
headers.Set("Content-Type", "application/tar")
|
||||||
|
|
||||||
|
query := url.Values{}
|
||||||
|
query.Set("name", createOptions.RepoName)
|
||||||
|
|
||||||
|
resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
ensureReaderClosed(resp)
|
||||||
|
return err
|
||||||
|
}
|
Loading…
Reference in New Issue