-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathplugin_push.go
More file actions
34 lines (29 loc) · 867 Bytes
/
plugin_push.go
File metadata and controls
34 lines (29 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package client
import (
"context"
"io"
"net/http"
"github.com/moby/moby/api/types/registry"
)
// PluginPushOptions holds parameters to push a plugin.
type PluginPushOptions struct {
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
}
// PluginPushResult is the result of a plugin push operation
type PluginPushResult struct {
io.ReadCloser
}
// PluginPush pushes a plugin to a registry
func (cli *Client) PluginPush(ctx context.Context, name string, options PluginPushOptions) (PluginPushResult, error) {
name, err := trimID("plugin", name)
if err != nil {
return PluginPushResult{}, err
}
resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, nil, http.Header{
registry.AuthHeader: {options.RegistryAuth},
})
if err != nil {
return PluginPushResult{}, err
}
return PluginPushResult{resp.Body}, nil
}