Alpine base image and some dependencies upgraded
Details in the reweave CHANGELOG
This commit is contained in:
1 parent
1ceeca80e6
commit
0d58e17954
368 files changed
+23406
-9163
No files matched your search
+108
-39
@@ -5,11 +5,11 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// PluginPrivilege represents a privilege for a plugin.
|
||||
@@ -36,15 +36,26 @@ type InstallPluginOptions struct {
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) InstallPlugins(opts InstallPluginOptions) error {
|
||||
headers, err := headersWithAuth(opts.Auth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
path := "/plugins/pull?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{
|
||||
data: opts.Plugins,
|
||||
context: opts.Context,
|
||||
headers: headers,
|
||||
})
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
// PullPlugin streams back the progress of the pull, we must consume the whole body
|
||||
// otherwise the pull will be canceled on the engine.
|
||||
if _, err := io.ReadAll(resp.Body); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -144,7 +155,7 @@ type PluginDetail struct {
|
||||
ID string `json:"Id,omitempty" yaml:"Id,omitempty" toml:"Id,omitempty"`
|
||||
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
|
||||
Tag string `json:"Tag,omitempty" yaml:"Tag,omitempty" toml:"Tag,omitempty"`
|
||||
Active bool `json:"Active,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
|
||||
Active bool `json:"Enabled,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
|
||||
Settings PluginSettings `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
|
||||
Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
|
||||
}
|
||||
@@ -153,7 +164,7 @@ type PluginDetail struct {
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) ListPlugins(ctx context.Context) ([]PluginDetail, error) {
|
||||
resp, err := c.do("GET", "/plugins", doOptions{
|
||||
resp, err := c.do(http.MethodGet, "/plugins", doOptions{
|
||||
context: ctx,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -167,12 +178,66 @@ func (c *Client) ListPlugins(ctx context.Context) ([]PluginDetail, error) {
|
||||
return pluginDetails, nil
|
||||
}
|
||||
|
||||
// GetPluginPrivileges returns pulginPrivileges or an error.
|
||||
// ListFilteredPluginsOptions specify parameters to the ListFilteredPlugins function.
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) GetPluginPrivileges(name string, ctx context.Context) ([]PluginPrivilege, error) {
|
||||
resp, err := c.do("GET", "/plugins/privileges?remote="+name, doOptions{
|
||||
context: ctx,
|
||||
type ListFilteredPluginsOptions struct {
|
||||
Filters map[string][]string
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
// ListFilteredPlugins returns pluginDetails or an error.
|
||||
//
|
||||
// See https://goo.gl/rmdmWg for more details.
|
||||
func (c *Client) ListFilteredPlugins(opts ListFilteredPluginsOptions) ([]PluginDetail, error) {
|
||||
path := "/plugins/json?" + queryString(opts)
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{
|
||||
context: opts.Context,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
pluginDetails := make([]PluginDetail, 0)
|
||||
if err := json.NewDecoder(resp.Body).Decode(&pluginDetails); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return pluginDetails, nil
|
||||
}
|
||||
|
||||
// GetPluginPrivileges returns pluginPrivileges or an error.
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) GetPluginPrivileges(remote string, ctx context.Context) ([]PluginPrivilege, error) {
|
||||
return c.GetPluginPrivilegesWithOptions(
|
||||
GetPluginPrivilegesOptions{
|
||||
Remote: remote,
|
||||
Context: ctx,
|
||||
})
|
||||
}
|
||||
|
||||
// GetPluginPrivilegesOptions specify parameters to the GetPluginPrivilegesWithOptions function.
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
type GetPluginPrivilegesOptions struct {
|
||||
Remote string
|
||||
Auth AuthConfiguration
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
// GetPluginPrivilegesWithOptions returns pluginPrivileges or an error.
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) GetPluginPrivilegesWithOptions(opts GetPluginPrivilegesOptions) ([]PluginPrivilege, error) {
|
||||
headers, err := headersWithAuth(opts.Auth)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
path := "/plugins/privileges?" + queryString(opts)
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{
|
||||
context: opts.Context,
|
||||
headers: headers,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -189,20 +254,17 @@ func (c *Client) GetPluginPrivileges(name string, ctx context.Context) ([]Plugin
|
||||
//
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) InspectPlugins(name string, ctx context.Context) (*PluginDetail, error) {
|
||||
resp, err := c.do("GET", "/plugins/"+name+"/json", doOptions{
|
||||
resp, err := c.do(http.MethodGet, "/plugins/"+name+"/json", doOptions{
|
||||
context: ctx,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return nil, &NoSuchPlugin{ID: name}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
defer resp.Body.Close()
|
||||
var pluginDetail PluginDetail
|
||||
if err := json.NewDecoder(resp.Body).Decode(&pluginDetail); err != nil {
|
||||
return nil, err
|
||||
@@ -226,20 +288,27 @@ type RemovePluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) RemovePlugin(opts RemovePluginOptions) (*PluginDetail, error) {
|
||||
path := "/plugins/" + opts.Name + "?" + queryString(opts)
|
||||
resp, err := c.do("DELETE", path, doOptions{context: opts.Context})
|
||||
resp, err := c.do(http.MethodDelete, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return nil, &NoSuchPlugin{ID: opts.Name}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
resp.Body.Close()
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(body) == 0 {
|
||||
// Seems like newer docker versions won't return the plugindetail after removal
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var pluginDetail PluginDetail
|
||||
if err := json.NewDecoder(resp.Body).Decode(&pluginDetail); err != nil {
|
||||
if err := json.Unmarshal(body, &pluginDetail); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pluginDetail, nil
|
||||
@@ -261,8 +330,7 @@ type EnablePluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) EnablePlugin(opts EnablePluginOptions) error {
|
||||
path := "/plugins/" + opts.Name + "/enable?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{context: opts.Context})
|
||||
defer resp.Body.Close()
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -285,8 +353,7 @@ type DisablePluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) DisablePlugin(opts DisablePluginOptions) error {
|
||||
path := "/plugins/" + opts.Name + "/disable"
|
||||
resp, err := c.do("POST", path, doOptions{context: opts.Context})
|
||||
defer resp.Body.Close()
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -311,14 +378,15 @@ type CreatePluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) CreatePlugin(opts CreatePluginOptions) (string, error) {
|
||||
path := "/plugins/create?" + queryString(opts)
|
||||
resp, err := c.do("POST", path, doOptions{
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{
|
||||
data: opts.Path,
|
||||
context: opts.Context})
|
||||
defer resp.Body.Close()
|
||||
context: opts.Context,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
containerNameBytes, err := ioutil.ReadAll(resp.Body)
|
||||
defer resp.Body.Close()
|
||||
containerNameBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -340,11 +408,11 @@ type PushPluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) PushPlugin(opts PushPluginOptions) error {
|
||||
path := "/plugins/" + opts.Name + "/push"
|
||||
resp, err := c.do("POST", path, doOptions{context: opts.Context})
|
||||
defer resp.Body.Close()
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{context: opts.Context})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -364,17 +432,18 @@ type ConfigurePluginOptions struct {
|
||||
// See https://goo.gl/C4t7Tz for more details.
|
||||
func (c *Client) ConfigurePlugin(opts ConfigurePluginOptions) error {
|
||||
path := "/plugins/" + opts.Name + "/set"
|
||||
resp, err := c.do("POST", path, doOptions{
|
||||
resp, err := c.do(http.MethodPost, path, doOptions{
|
||||
data: opts.Envs,
|
||||
context: opts.Context,
|
||||
})
|
||||
defer resp.Body.Close()
|
||||
if err != nil {
|
||||
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return &NoSuchPlugin{ID: opts.Name}
|
||||
}
|
||||
return err
|
||||
}
|
||||
resp.Body.Close()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user