Skip to content

Commit

Permalink
[Fix] method/type comments & some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesmoke05 committed Feb 11, 2018
1 parent e4f49da commit 011e905
Showing 1 changed file with 81 additions and 73 deletions.
154 changes: 81 additions & 73 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,23 @@ type PluginPrivilege struct {
Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
}

// InstallPluginOptions .This is a TBD Comments.
// InstallPluginOptions
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type InstallPluginOptions struct {
Remote string
Name string
Plugins []PluginPrivilege
Plugins []PluginPrivilege `qs:"-"`

Auth AuthConfiguration

Context context.Context
}

// InstallPlugins returns a slice of containers matching the given criteria.
// InstallPlugins installs a plugin or returns an error in case of failure.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) InstallPlugins(opts InstallPluginOptions, auth AuthConfiguration) error {
// See https://goo.gl/C4t7Tz for more details.
func (c *Client) InstallPlugins(opts InstallPluginOptions) error {
params := make(url.Values)
params.Set("remote", opts.Remote)
if opts.Name != "" {
Expand All @@ -51,80 +54,80 @@ func (c *Client) InstallPlugins(opts InstallPluginOptions, auth AuthConfiguratio
return nil
}

// PluginSetting .This is a TBD Comments.
// PluginSetting stores plugin settings.
//
// See https://goo.gl/kaOHGw for more details.
type PluginSetting struct {
// See https://goo.gl/C4t7Tz for more details.
type PluginSettings struct {
Env []string `json:"Env,omitempty" yaml:"Env,omitempty" toml:"Env,omitempty"`
Args []string `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
Devices []string `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
}

// PluginInterface .This is a TBD Comments.
// PluginInterface stores plugin interface.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginInterface struct {
Types []string `json:"Types,omitempty" yaml:"Types,omitempty" toml:"Types,omitempty"`
Socket string `json:"Socket,omitempty" yaml:"Socket,omitempty" toml:"Socket,omitempty"`
}

// PluginNetwork .This is a TBD Comments.
// PluginNetwork stores plugin network type.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginNetwork struct {
Type string `json:"Type,omitempty" yaml:"Type,omitempty" toml:"Type,omitempty"`
}

// PluginLinux .This is a TBD Comments.
// PluginLinux stores plugin linux setting.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginLinux struct {
Capabilities []string `json:"Capabilities,omitempty" yaml:"Capabilities,omitempty" toml:"Capabilities,omitempty"`
AllowAllDevices bool `json:"AllowAllDevices,omitempty" yaml:"AllowAllDevices,omitempty" toml:"AllowAllDevices,omitempty"`
Devices []PluginLinuxDevices `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
}

// PluginLinuxDevices .This is a TBD Comments.
// PluginLinuxDevices stores plugin linux device setting.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginLinuxDevices struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
Path string `json:"Path,omitempty" yaml:"Path,omitempty" toml:"Path,omitempty"`
}

// PluginEnv .This is a TBD Comments.
// PluginEnv stores plugin environment.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginEnv struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
Value string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
}

// PluginArgs .This is a TBD Comments.
// PluginArgs stores plugin arguments.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginArgs struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
}

// PluginUser .This is a TBD Comments.
// PluginUser stores plugin user.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginUser struct {
UID int32 `json:"UID,omitempty" yaml:"UID,omitempty" toml:"UID,omitempty"`
GID int32 `json:"GID,omitempty" yaml:"GID,omitempty" toml:"GID,omitempty"`
}

// PluginConfig .This is a TBD Comments.
// PluginConfig stores plugin config.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PluginConfig struct {
Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
Documentation string
Expand All @@ -140,23 +143,26 @@ type PluginConfig struct {
Args PluginArgs `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
}

// PluginDetail .This is a TBD Comments.
// PluginDetail specify results from the ListPlugins function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
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"`
Settings PluginSetting `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
Settings PluginSettings `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
}

// ListPlugins .This is a TBD Comments.
// ListPlugins returns pluginDetails or an error.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) ListPlugins() ([]PluginDetail, error) {
resp, err := c.do("GET", "/plugins", doOptions{})
// See https://goo.gl/C4t7Tz for more details.
func (c *Client) ListPlugins(ctx context.Context) ([]PluginDetail, error) {
resp, err := c.do("GET", "/plugins", doOptions{
context:ctx,

})
if err != nil {
return nil, err
}
Expand All @@ -168,11 +174,13 @@ func (c *Client) ListPlugins() ([]PluginDetail, error) {
return pluginDetails, nil
}

// GetPluginPrivileges .This is a TBD Comments.
// GetPluginPrivileges returns pulginPrivileges or an error.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) GetPluginPrivileges(name string) ([]PluginPrivilege, error) {
resp, err := c.do("GET", "/plugins/privileges?"+name, doOptions{})
// 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,
})
if err != nil {
return nil, err
}
Expand All @@ -184,11 +192,13 @@ func (c *Client) GetPluginPrivileges(name string) ([]PluginPrivilege, error) {
return pluginPrivileges, nil
}

// InspectPlugins .This is a TBD Comments.
// InspectPlugins returns a pluginDetail or an error.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) InspectPlugins(name string) (*PluginDetail, error) {
resp, err := c.do("GET", "/plugins/"+name+"/json", doOptions{})
// 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{
context:ctx,
})
if err != nil {
return nil, err
}
Expand All @@ -207,22 +217,20 @@ func (c *Client) InspectPlugins(name string) (*PluginDetail, error) {
return &pluginDetail, nil
}

// RemovePluginOptions .This is a TBD Comments.
// RemovePluginOptions specify parameters to the RemovePlugin function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type RemovePluginOptions struct {
// The ID of the container.
// The Name of the plugin.
Name string `qs:"-"`

// A flag that indicates whether Docker should remove the plugin
// even if it is currently used.
Force bool `qs:"force"`
Context context.Context
}

// RemovePlugin .This is a TBD Comments.
// RemovePlugin returns a PluginDetail or an error.
//
// See https://goo.gl/kaOHGw for more details.
// 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})
Expand All @@ -244,20 +252,20 @@ func (c *Client) RemovePlugin(opts RemovePluginOptions) (*PluginDetail, error) {
return &pluginDetail, nil
}

// EnablePluginOptions .This is a TBD Comments.
// EnablePluginOptions specify parameters to the EnablePlugin function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type EnablePluginOptions struct {
// The ID of the container.
// The Name of the plugin.
Name string `qs:"-"`
Timeout int64 `qs:"timeout"`

Context context.Context
}

// EnablePlugin .This is a TBD Comments.
// EnablePlugin enables plugin that opts point or returns an error.
//
// See https://goo.gl/kaOHGw for more details.
// 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})
Expand All @@ -269,19 +277,19 @@ func (c *Client) EnablePlugin(opts EnablePluginOptions) error {
return nil
}

// DisablePluginOptions .This is a TBD Comments.
// DisablePluginOptions specify parameters to the DisablePlugin function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type DisablePluginOptions struct {
// The ID of the container.
// The Name of the plugin.
Name string `qs:"-"`

Context context.Context
}

// DisablePlugin .This is a TBD Comments.
// DisablePlugin disables plugin that opts point or returns an error.
//
// See https://goo.gl/kaOHGw for more details.
// 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})
Expand All @@ -293,23 +301,23 @@ func (c *Client) DisablePlugin(opts DisablePluginOptions) error {
return nil
}

// CreatePluginOptions .This is a TBD Comments.
// CreatePluginOptions specify parameters to the CreatePlugin function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type CreatePluginOptions struct {
// The Name of the container.
// The Name of the plugin.
Name string `qs:"name"`
// Path to tar containing plugin
Path string `qs:"-"`

Context context.Context
}

// CreatePlugin .This is a TBD Comments.
// CreatePlugin creates plugin that opts point or returns an error.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
func (c *Client) CreatePlugin(opts CreatePluginOptions) (string, error) {
path := "/plugins/create?" + queryString(opts.Name)
path := "/plugins/create?" + queryString(opts)
resp, err := c.do("POST", path, doOptions{
data: opts.Path,
context: opts.Context})
Expand All @@ -324,19 +332,19 @@ func (c *Client) CreatePlugin(opts CreatePluginOptions) (string, error) {
return string(containerNameBytes), nil
}

// PushPluginOptions .This is a TBD Comments.
// PushPluginOptions specify parameters to PushPlugin function.
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type PushPluginOptions struct {
// The Name of the container.
// The Name of the plugin.
Name string

Context context.Context
}

// PushPlugin .This is a TBD Comments.
// PushPlugin pushes plugin that opts point or returns an error.
//
// See https://goo.gl/kaOHGw for more details.
// 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})
Expand All @@ -347,20 +355,20 @@ func (c *Client) PushPlugin(opts PushPluginOptions) error {
return nil
}

// ConfigurePluginOptions .This is a TBD Comments.
// ConfigurePluginOptions specify parameters to the ConfigurePlugin
//
// See https://goo.gl/kaOHGw for more details.
// See https://goo.gl/C4t7Tz for more details.
type ConfigurePluginOptions struct {
// The Name of the container.
// The Name of the plugin.
Name string `qs:"name"`
Envs []string

Context context.Context
}

// ConfigurePlugin .This is a TBD Comments.
// ConfigurePlugin configures plugin that opts point or returns an error.
//
// See https://goo.gl/kaOHGw for more details.
// 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{
Expand Down

0 comments on commit 011e905

Please sign in to comment.