Files
moby/client/plugin_push.go
T
Sebastiaan van Stijn b20c3db932 client: request: use consistent order or arguments
Make `body` the last argument, so that requests can be inlined on call-sites.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-29 14:14:26 +02:00

34 lines
881 B
Go

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
}
headers := http.Header{registry.AuthHeader: {options.RegistryAuth}}
resp, err := cli.post(ctx, "/plugins/"+name+"/push", nil, headers, nil)
if err != nil {
return PluginPushResult{}, err
}
return PluginPushResult{resp.Body}, nil
}