@@ -6,110 +6,112 @@ package docker
66
77import (
88 "encoding/json"
9+ ioutil "io/ioutil"
910 "net/http"
1011 "net/url"
12+
1113 "golang.org/x/net/context"
12- ioutil "io/ioutil"
1314)
1415
15-
1616// PluginPrivilege represents a privilege for a plugin.
1717type PluginPrivilege struct {
18- Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
19- Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
20- Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
18+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
19+ Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
20+ Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
2121}
2222
2323// InstallPluginOptions This is a TBD Comments.
2424//
2525// See https://goo.gl/kaOHGw for more details.
2626type InstallPluginOptions struct {
27- Remote string
28- Name string
27+ Remote string
28+ Name string
2929 Plugins []PluginPrivilege
3030 Context context.Context
3131}
3232
3333// InstallPlugins returns a slice of containers matching the given criteria.
3434//
3535// See https://goo.gl/kaOHGw for more details.
36- func (c * Client ) InstallPlugins (opts InstallPluginOptions , auth AuthConfiguration ) ( error ) {
36+ func (c * Client ) InstallPlugins (opts InstallPluginOptions , auth AuthConfiguration ) error {
3737 params := make (url.Values )
3838 params .Set ("remote" , opts .Remote )
39- if opts .Name != "" {
39+ if opts .Name != "" {
4040 params .Set ("name" , opts .Name )
4141 }
4242 path := "/plugins/pull?" + queryString (params )
4343 resp , err := c .do ("POST" , path , doOptions {
44- data : opts .Plugins ,
45- context : opts .Context ,
44+ data : opts .Plugins ,
45+ context : opts .Context ,
4646 })
4747 defer resp .Body .Close ()
48- if err != nil {return err }
49- return nil
48+ if err != nil {
49+ return err
50+ }
51+ return nil
5052}
5153
5254// PluginSetting This is a TBD Comments.
5355//
5456// See https://goo.gl/kaOHGw for more details.
5557type PluginSetting struct {
56- Env []string `json:"Env,omitempty" yaml:"Env,omitempty" toml:"Env,omitempty"`
57- Args []string `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
58- Devices []string `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
58+ Env []string `json:"Env,omitempty" yaml:"Env,omitempty" toml:"Env,omitempty"`
59+ Args []string `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
60+ Devices []string `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
5961}
6062
6163// PluginInterface This is a TBD Comments.
6264//
6365// See https://goo.gl/kaOHGw for more details.
6466type PluginInterface struct {
65- Types []string `json:"Types,omitempty" yaml:"Types,omitempty" toml:"Types,omitempty"`
66- Socket string `json:"Socket,omitempty" yaml:"Socket,omitempty" toml:"Socket,omitempty"`
67+ Types []string `json:"Types,omitempty" yaml:"Types,omitempty" toml:"Types,omitempty"`
68+ Socket string `json:"Socket,omitempty" yaml:"Socket,omitempty" toml:"Socket,omitempty"`
6769}
6870
6971// PluginNetwork This is a TBD Comments.
7072//
7173// See https://goo.gl/kaOHGw for more details.
7274type PluginNetwork struct {
73- Type string `json:"Type,omitempty" yaml:"Type,omitempty" toml:"Type,omitempty"`
75+ Type string `json:"Type,omitempty" yaml:"Type,omitempty" toml:"Type,omitempty"`
7476}
7577
7678// PluginLinux This is a TBD Comments.
7779//
7880// See https://goo.gl/kaOHGw for more details.
7981type PluginLinux struct {
80- Capabilities []string `json:"Capabilities,omitempty" yaml:"Capabilities,omitempty" toml:"Capabilities,omitempty"`
81- AllowAllDevices bool `json:"AllowAllDevices,omitempty" yaml:"AllowAllDevices,omitempty" toml:"AllowAllDevices,omitempty"`
82- Devices []PluginLinuxDevices `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
82+ Capabilities []string `json:"Capabilities,omitempty" yaml:"Capabilities,omitempty" toml:"Capabilities,omitempty"`
83+ AllowAllDevices bool `json:"AllowAllDevices,omitempty" yaml:"AllowAllDevices,omitempty" toml:"AllowAllDevices,omitempty"`
84+ Devices []PluginLinuxDevices `json:"Devices,omitempty" yaml:"Devices,omitempty" toml:"Devices,omitempty"`
8385}
8486
8587// PluginLinuxDevices This is a TBD Comments.
8688//
8789// See https://goo.gl/kaOHGw for more details.
8890type PluginLinuxDevices struct {
89- Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
90- Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
91- Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
92- Path string `json:"Path,omitempty" yaml:"Path,omitempty" toml:"Path,omitempty"`
91+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
92+ Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
93+ Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
94+ Path string `json:"Path,omitempty" yaml:"Path,omitempty" toml:"Path,omitempty"`
9395}
9496
9597// PluginEnv This is a TBD Comments.
9698//
9799// See https://goo.gl/kaOHGw for more details.
98100type PluginEnv struct {
99- Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
100- Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
101- Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
102- Value string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
101+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
102+ Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
103+ Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
104+ Value string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
103105}
104106
105107// PluginArgs This is a TBD Comments.
106108//
107109// See https://goo.gl/kaOHGw for more details.
108110type PluginArgs struct {
109- Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
110- Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
111- Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
112- Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
111+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
112+ Description string `json:"Documentation,omitempty" yaml:"Documentation,omitempty" toml:"Documentation,omitempty"`
113+ Settable []string `json:"Settable,omitempty" yaml:"Settable,omitempty" toml:"Settable,omitempty"`
114+ Value []string `json:"Value,omitempty" yaml:"Value,omitempty" toml:"Value,omitempty"`
113115}
114116
115117// PluginUser This is a TBD Comments.
@@ -124,42 +126,42 @@ type PluginUser struct {
124126//
125127// See https://goo.gl/kaOHGw for more details.
126128type PluginConfig struct {
127- Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
128- Documentation string
129- Interface PluginInterface `json:"Interface,omitempty" yaml:"Interface,omitempty" toml:"Interface,omitempty"`
130- Entrypoint []string `json:"Entrypoint,omitempty" yaml:"Entrypoint,omitempty" toml:"Entrypoint,omitempty"`
131- WorkDir string `json:"WorkDir,omitempty" yaml:"WorkDir,omitempty" toml:"WorkDir,omitempty"`
132- User PluginUser `json:"User,omitempty" yaml:"User,omitempty" toml:"User,omitempty"`
133- Network PluginNetwork `json:"Network,omitempty" yaml:"Network,omitempty" toml:"Network,omitempty"`
134- Linux PluginLinux `json:"Linux,omitempty" yaml:"Linux,omitempty" toml:"Linux,omitempty"`
135- PropagatedMount string `json:"PropagatedMount,omitempty" yaml:"PropagatedMount,omitempty" toml:"PropagatedMount,omitempty"`
136- Mounts []Mount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"`
137- Env []PluginEnv `json:"Env,omitempty" yaml:"Env,omitempty" toml:"Env,omitempty"`
138- Args PluginArgs `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
129+ Description string `json:"Description,omitempty" yaml:"Description,omitempty" toml:"Description,omitempty"`
130+ Documentation string
131+ Interface PluginInterface `json:"Interface,omitempty" yaml:"Interface,omitempty" toml:"Interface,omitempty"`
132+ Entrypoint []string `json:"Entrypoint,omitempty" yaml:"Entrypoint,omitempty" toml:"Entrypoint,omitempty"`
133+ WorkDir string `json:"WorkDir,omitempty" yaml:"WorkDir,omitempty" toml:"WorkDir,omitempty"`
134+ User PluginUser `json:"User,omitempty" yaml:"User,omitempty" toml:"User,omitempty"`
135+ Network PluginNetwork `json:"Network,omitempty" yaml:"Network,omitempty" toml:"Network,omitempty"`
136+ Linux PluginLinux `json:"Linux,omitempty" yaml:"Linux,omitempty" toml:"Linux,omitempty"`
137+ PropagatedMount string `json:"PropagatedMount,omitempty" yaml:"PropagatedMount,omitempty" toml:"PropagatedMount,omitempty"`
138+ Mounts []Mount `json:"Mounts,omitempty" yaml:"Mounts,omitempty" toml:"Mounts,omitempty"`
139+ Env []PluginEnv `json:"Env,omitempty" yaml:"Env,omitempty" toml:"Env,omitempty"`
140+ Args PluginArgs `json:"Args,omitempty" yaml:"Args,omitempty" toml:"Args,omitempty"`
139141}
140142
141143// PluginDetail This is a TBD Comments.
142144//
143145// See https://goo.gl/kaOHGw for more details.
144146type PluginDetail struct {
145- ID string `json:"Id,omitempty" yaml:"Id,omitempty" toml:"Id,omitempty"`
146- Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
147- Tag string `json:"Tag,omitempty" yaml:"Tag,omitempty" toml:"Tag,omitempty"`
148- Active bool `json:"Active,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
149- Settings PluginSetting `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
150- Config Config `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
147+ ID string `json:"Id,omitempty" yaml:"Id,omitempty" toml:"Id,omitempty"`
148+ Name string `json:"Name,omitempty" yaml:"Name,omitempty" toml:"Name,omitempty"`
149+ Tag string `json:"Tag,omitempty" yaml:"Tag,omitempty" toml:"Tag,omitempty"`
150+ Active bool `json:"Active,omitempty" yaml:"Active,omitempty" toml:"Active,omitempty"`
151+ Settings PluginSetting `json:"Settings,omitempty" yaml:"Settings,omitempty" toml:"Settings,omitempty"`
152+ Config PluginConfig `json:"Config,omitempty" yaml:"Config,omitempty" toml:"Config,omitempty"`
151153}
152154
153155// ListPlugins This is a TBD Comments.
154156//
155157// See https://goo.gl/kaOHGw for more details.
156- func (c * Client ) ListPlugins ()([]PluginDetail , error ) {
157- resp , err := c .do ("GET" , "/plugins" ,doOptions {})
158+ func (c * Client ) ListPlugins () ([]PluginDetail , error ) {
159+ resp , err := c .do ("GET" , "/plugins" , doOptions {})
158160 if err != nil {
159161 return nil , err
160162 }
161163 defer resp .Body .Close ()
162- pluginDetails := make ([]PluginDetail ,0 )
164+ pluginDetails := make ([]PluginDetail , 0 )
163165 if err := json .NewDecoder (resp .Body ).Decode (& pluginDetails ); err != nil {
164166 return nil , err
165167 }
@@ -169,13 +171,13 @@ func (c *Client) ListPlugins()([]PluginDetail, error) {
169171// GetPluginPrivileges This is a TBD Comments.
170172//
171173// See https://goo.gl/kaOHGw for more details.
172- func (c * Client ) GetPluginPrivileges (name string )([]PluginPrivilege , error ) {
173- resp , err := c .do ("GET" , "/plugins/privileges?" + name ,doOptions {})
174+ func (c * Client ) GetPluginPrivileges (name string ) ([]PluginPrivilege , error ) {
175+ resp , err := c .do ("GET" , "/plugins/privileges?" + name , doOptions {})
174176 if err != nil {
175177 return nil , err
176178 }
177179 defer resp .Body .Close ()
178- pluginPrivileges := make ([]PluginPrivilege ,0 )
180+ pluginPrivileges := make ([]PluginPrivilege , 0 )
179181 if err := json .NewDecoder (resp .Body ).Decode (& pluginPrivileges ); err != nil {
180182 return nil , err
181183 }
@@ -191,25 +193,25 @@ type RemovePluginOptions struct {
191193
192194 // A flag that indicates whether Docker should remove the plugin
193195 // even if it is currently used.
194- Force bool `qs:"force"`
196+ Force bool `qs:"force"`
195197 Context context.Context
196198}
197199
198200// RemovePlugin This is a TBD Comments.
199201//
200202// See https://goo.gl/kaOHGw for more details.
201- func (c * Client ) RemovePlugin (opts RemovePluginOptions )(* PluginDetail , error ) {
202- path := "/plugins/" + opts .Name + "?" + queryString (opts )
203+ func (c * Client ) RemovePlugin (opts RemovePluginOptions ) (* PluginDetail , error ) {
204+ path := "/plugins/" + opts .Name + "?" + queryString (opts )
203205 resp , err := c .do ("DELETE" , path , doOptions {context : opts .Context })
204206 if err != nil {
205207 return nil , err
206208 }
207209 defer resp .Body .Close ()
208210 if err != nil {
209211 if e , ok := err .(* Error ); ok && e .Status == http .StatusNotFound {
210- return nil ,& NoSuchPlugin {ID : opts .Name }
212+ return nil , & NoSuchPlugin {ID : opts .Name }
211213 }
212- return nil ,err
214+ return nil , err
213215 }
214216 resp .Body .Close ()
215217 var pluginDetail PluginDetail
@@ -224,17 +226,17 @@ func (c *Client) RemovePlugin(opts RemovePluginOptions)(*PluginDetail, error) {
224226// See https://goo.gl/kaOHGw for more details.
225227type EnablePluginOptions struct {
226228 // The ID of the container.
227- Name string `qs:"-"`
228- Timeout int64 `qs:"timeout"`
229+ Name string `qs:"-"`
230+ Timeout int64 `qs:"timeout"`
229231
230232 Context context.Context
231233}
232234
233235// EnablePlugin This is a TBD Comments.
234236//
235237// See https://goo.gl/kaOHGw for more details.
236- func (c * Client ) EnablePlugin (opts EnablePluginOptions )( error ) {
237- path := "/plugins/" + opts .Name + "/enable?" + queryString (opts )
238+ func (c * Client ) EnablePlugin (opts EnablePluginOptions ) error {
239+ path := "/plugins/" + opts .Name + "/enable?" + queryString (opts )
238240 resp , err := c .do ("POST" , path , doOptions {context : opts .Context })
239241 defer resp .Body .Close ()
240242 if err != nil {
@@ -257,8 +259,8 @@ type DisablePluginOptions struct {
257259// DisablePlugin This is a TBD Comments.
258260//
259261// See https://goo.gl/kaOHGw for more details.
260- func (c * Client ) DisablePlugin (opts DisablePluginOptions )( error ) {
261- path := "/plugins/" + opts .Name + "/disable"
262+ func (c * Client ) DisablePlugin (opts DisablePluginOptions ) error {
263+ path := "/plugins/" + opts .Name + "/disable"
262264 resp , err := c .do ("POST" , path , doOptions {context : opts .Context })
263265 defer resp .Body .Close ()
264266 if err != nil {
@@ -283,20 +285,20 @@ type CreatePluginOptions struct {
283285// CreatePlugin This is a TBD Comments.
284286//
285287// See https://goo.gl/kaOHGw for more details.
286- func (c * Client ) CreatePlugin (opts CreatePluginOptions )(string ,error ) {
287- path := "/plugins/create?" + queryString (opts .Name )
288+ func (c * Client ) CreatePlugin (opts CreatePluginOptions ) (string , error ) {
289+ path := "/plugins/create?" + queryString (opts .Name )
288290 resp , err := c .do ("POST" , path , doOptions {
289291 data : opts .Path ,
290292 context : opts .Context })
291293 defer resp .Body .Close ()
292294 if err != nil {
293- return "" ,err
295+ return "" , err
294296 }
295297 containerNameBytes , err := ioutil .ReadAll (resp .Body )
296298 if err != nil {
297- return "" ,err
299+ return "" , err
298300 }
299- return string (containerNameBytes ),nil
301+ return string (containerNameBytes ), nil
300302}
301303
302304// PushPluginOptions This is a TBD Comments.
@@ -312,8 +314,8 @@ type PushPluginOptions struct {
312314// PushPlugin This is a TBD Comments.
313315//
314316// See https://goo.gl/kaOHGw for more details.
315- func (c * Client ) PushPlugin (opts PushPluginOptions )( error ) {
316- path := "/plugins/" + opts .Name + "/push"
317+ func (c * Client ) PushPlugin (opts PushPluginOptions ) error {
318+ path := "/plugins/" + opts .Name + "/push"
317319 resp , err := c .do ("POST" , path , doOptions {context : opts .Context })
318320 defer resp .Body .Close ()
319321 if err != nil {
@@ -336,12 +338,12 @@ type ConfigurePluginOptions struct {
336338// ConfigurePlugin This is a TBD Comments.
337339//
338340// See https://goo.gl/kaOHGw for more details.
339- func (c * Client ) ConfigurePlugin (opts ConfigurePluginOptions )( error ) {
340- path := "/plugins/" + opts .Name + "/set"
341+ func (c * Client ) ConfigurePlugin (opts ConfigurePluginOptions ) error {
342+ path := "/plugins/" + opts .Name + "/set"
341343 resp , err := c .do ("POST" , path , doOptions {
342- data :opts .Envs ,
344+ data : opts .Envs ,
343345 context : opts .Context ,
344- })
346+ })
345347 defer resp .Body .Close ()
346348 if err != nil {
347349 if e , ok := err .(* Error ); ok && e .Status == http .StatusNotFound {
0 commit comments