Skip to content

Commit

Permalink
[Add] full tests for plugin api
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesmoke05 committed Feb 8, 2018
1 parent 6b2bf29 commit e4f49da
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 30 deletions.
79 changes: 51 additions & 28 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type PluginPrivilege struct {
Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
}

// InstallPluginOptions This is a TBD Comments.
// InstallPluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type InstallPluginOptions struct {
Expand Down Expand Up @@ -51,7 +51,7 @@ func (c *Client) InstallPlugins(opts InstallPluginOptions, auth AuthConfiguratio
return nil
}

// PluginSetting This is a TBD Comments.
// PluginSetting .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginSetting struct {
Expand All @@ -60,22 +60,22 @@ type PluginSetting struct {
Devices []string `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
}

// PluginInterface This is a TBD Comments.
// PluginInterface .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw 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 .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginNetwork struct {
Type string `json:"Type,omitempty" yaml:"Type,omitempty" toml:"Type,omitempty"`
}

// PluginLinux This is a TBD Comments.
// PluginLinux .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginLinux struct {
Expand All @@ -84,7 +84,7 @@ type PluginLinux struct {
Devices []PluginLinuxDevices `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
}

// PluginLinuxDevices This is a TBD Comments.
// PluginLinuxDevices .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginLinuxDevices struct {
Expand All @@ -94,35 +94,35 @@ type PluginLinuxDevices struct {
Path string `json:"Path,omitempty" yaml:"Path,omitempty" toml:"Path,omitempty"`
}

// PluginEnv This is a TBD Comments.
// PluginEnv .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginEnv struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,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 .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginArgs struct {
Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,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 .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw 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 .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginConfig struct {
Expand All @@ -140,7 +140,7 @@ type PluginConfig struct {
Args PluginArgs `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
}

// PluginDetail This is a TBD Comments.
// PluginDetail .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PluginDetail struct {
Expand All @@ -152,7 +152,7 @@ type PluginDetail struct {
Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
}

// ListPlugins This is a TBD Comments.
// ListPlugins .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) ListPlugins() ([]PluginDetail, error) {
Expand All @@ -168,7 +168,7 @@ func (c *Client) ListPlugins() ([]PluginDetail, error) {
return pluginDetails, nil
}

// GetPluginPrivileges This is a TBD Comments.
// GetPluginPrivileges .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) GetPluginPrivileges(name string) ([]PluginPrivilege, error) {
Expand All @@ -177,14 +177,37 @@ func (c *Client) GetPluginPrivileges(name string) ([]PluginPrivilege, error) {
return nil, err
}
defer resp.Body.Close()
pluginPrivileges := make([]PluginPrivilege, 0)
var pluginPrivileges []PluginPrivilege
if err := json.NewDecoder(resp.Body).Decode(&pluginPrivileges); err != nil {
return nil, err
}
return pluginPrivileges, nil
}

// RemovePluginOptions This is a TBD Comments.
// InspectPlugins .This is a TBD Comments.
//
// 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{})
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err != nil {
if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
return nil, &NoSuchPlugin{ID: name}
}
return nil, err
}
resp.Body.Close()
var pluginDetail PluginDetail
if err := json.NewDecoder(resp.Body).Decode(&pluginDetail); err != nil {
return nil, err
}
return &pluginDetail, nil
}

// RemovePluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type RemovePluginOptions struct {
Expand All @@ -197,7 +220,7 @@ type RemovePluginOptions struct {
Context context.Context
}

// RemovePlugin This is a TBD Comments.
// RemovePlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) RemovePlugin(opts RemovePluginOptions) (*PluginDetail, error) {
Expand All @@ -221,7 +244,7 @@ func (c *Client) RemovePlugin(opts RemovePluginOptions) (*PluginDetail, error) {
return &pluginDetail, nil
}

// EnablePluginOptions This is a TBD Comments.
// EnablePluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type EnablePluginOptions struct {
Expand All @@ -232,7 +255,7 @@ type EnablePluginOptions struct {
Context context.Context
}

// EnablePlugin This is a TBD Comments.
// EnablePlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) EnablePlugin(opts EnablePluginOptions) error {
Expand All @@ -246,7 +269,7 @@ func (c *Client) EnablePlugin(opts EnablePluginOptions) error {
return nil
}

// DisablePluginOptions This is a TBD Comments.
// DisablePluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type DisablePluginOptions struct {
Expand All @@ -256,7 +279,7 @@ type DisablePluginOptions struct {
Context context.Context
}

// DisablePlugin This is a TBD Comments.
// DisablePlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) DisablePlugin(opts DisablePluginOptions) error {
Expand All @@ -270,7 +293,7 @@ func (c *Client) DisablePlugin(opts DisablePluginOptions) error {
return nil
}

// CreatePluginOptions This is a TBD Comments.
// CreatePluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type CreatePluginOptions struct {
Expand All @@ -282,7 +305,7 @@ type CreatePluginOptions struct {
Context context.Context
}

// CreatePlugin This is a TBD Comments.
// CreatePlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) CreatePlugin(opts CreatePluginOptions) (string, error) {
Expand All @@ -301,7 +324,7 @@ func (c *Client) CreatePlugin(opts CreatePluginOptions) (string, error) {
return string(containerNameBytes), nil
}

// PushPluginOptions This is a TBD Comments.
// PushPluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type PushPluginOptions struct {
Expand All @@ -311,7 +334,7 @@ type PushPluginOptions struct {
Context context.Context
}

// PushPlugin This is a TBD Comments.
// PushPlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) PushPlugin(opts PushPluginOptions) error {
Expand All @@ -324,7 +347,7 @@ func (c *Client) PushPlugin(opts PushPluginOptions) error {
return nil
}

// ConfigurePluginOptions This is a TBD Comments.
// ConfigurePluginOptions .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
type ConfigurePluginOptions struct {
Expand All @@ -335,7 +358,7 @@ type ConfigurePluginOptions struct {
Context context.Context
}

// ConfigurePlugin This is a TBD Comments.
// ConfigurePlugin .This is a TBD Comments.
//
// See https://goo.gl/kaOHGw for more details.
func (c *Client) ConfigurePlugin(opts ConfigurePluginOptions) error {
Expand Down
Loading

0 comments on commit e4f49da

Please sign in to comment.