dockerapi 0.4.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/bin/setup CHANGED
@@ -1,8 +1,22 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
4
+ #set -vx
7
5
 
8
6
  # Do any other automated setup that you need to do here
7
+ if [ $USER == 'root' ]
8
+ then
9
+ echo "Enabling TCP port 2375 for external connection to Docker"
10
+ echo '{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}' > /etc/docker/daemon.json
11
+ mkdir -p /etc/systemd/system/docker.service.d
12
+ echo '[Service]' > /etc/systemd/system/docker.service.d/override.conf
13
+ echo 'ExecStart=' >> /etc/systemd/system/docker.service.d/override.conf
14
+ echo 'ExecStart=/usr/bin/dockerd' >> /etc/systemd/system/docker.service.d/override.conf
15
+ systemctl daemon-reload
16
+ systemctl restart docker.service
17
+ echo "Done!"
18
+ else
19
+ echo "Running bundle install"
20
+ bundle install
21
+ echo "Run this script as root for further configurations"
22
+ fi
@@ -1,33 +1,35 @@
1
1
  module Docker
2
2
  module API
3
3
  class Base
4
+
5
+ def initialize connection = nil
6
+ raise Docker::API::Error.new("Expect connection to be a Docker::API::Connection class") if connection != nil && !connection.is_a?(Docker::API::Connection)
7
+ @connection = connection || Docker::API::Connection.new
8
+ end
4
9
 
5
10
  private
6
11
 
7
- def self.base_path
12
+ def base_path # TODO: this method to be removed?
8
13
  "/"
9
14
  end
10
15
 
11
- def self.connection
12
- Docker::API::Connection.instance
13
- end
14
-
15
- def self.validate error, permitted_keys, params
16
- not_permitted = params.keys.map(&:to_s) - permitted_keys.map(&:to_s)
17
- raise error if not_permitted.size > 0
16
+ def validate error, permitted, params
17
+ return if params[:skip_validation]
18
+ unpermitted = params.keys.map(&:to_s) - permitted.map(&:to_s)
19
+ raise error.new(permitted, unpermitted) if unpermitted.size > 0
18
20
  end
19
21
 
20
22
  ## Converts Ruby Hash into query parameters
21
23
  ## In general, the format is key=value
22
24
  ## If value is another Hash, it should keep a json syntax {key:value}
23
- def self.hash_to_params h
25
+ def hash_to_params h
24
26
  p = []
25
- h.each { |k,v| p.push( v.is_a?(Hash) ? "#{k}=#{v.to_json}" : "#{k}=#{v}") }
27
+ h.delete_if{ | k, v | k.to_s == "skip_validation" }.each { |k,v| p.push( v.is_a?(Hash) ? "#{k}=#{v.to_json}" : "#{k}=#{v}") }
26
28
  p.join("&").gsub(" ","")
27
29
  end
28
30
 
29
- def self.build_path path, params = {}
30
- p = path.is_a?(Array) ? ([base_path] << path).join("/") : path
31
+ def build_path path, params = {}
32
+ p = path.is_a?(Array) ? ([base_path] << path).join("/") : path # TODO: this line to be removed?
31
33
  params.size > 0 ? [p, hash_to_params(params)].join("?") : p
32
34
  end
33
35
 
@@ -1,26 +1,18 @@
1
- require "excon"
2
- require "singleton"
3
- require "json"
4
1
  module Docker
5
2
  module API
6
3
  class Connection
7
- include Singleton
8
-
9
4
  [:get, :post, :head, :delete, :put].each do | method |
10
5
  define_method(method) { | path | self.request(method: method, path: path) }
11
6
  end
12
7
 
13
- def post(path, body = nil)
14
- self.request(method: :post, path: path, headers: { "Content-Type" => "application/json" }, body: body.to_json)
15
- end
16
-
17
8
  def request params
18
- @connection.request(params)
9
+ Docker::API::Response.new(@connection.request(params).data)
19
10
  end
20
11
 
21
- private
22
- def initialize
23
- @connection = Excon.new('unix:///', :socket => '/var/run/docker.sock')
12
+ def initialize url = nil, params = nil
13
+ url ||= 'unix:///'
14
+ params ||= url == 'unix:///' ? {socket: '/var/run/docker.sock'} : {}
15
+ @connection = Excon.new(url, params)
24
16
  end
25
17
 
26
18
  end
@@ -5,111 +5,113 @@ module Docker
5
5
 
6
6
  class Container < Docker::API::Base
7
7
 
8
- def self.base_path
8
+ def base_path
9
9
  "/containers"
10
10
  end
11
11
 
12
- def self.list params = {}
13
- validate Docker::API::InvalidParameter, [:all, :limit, :size, :filters], params
14
- connection.get(build_path(["json"], params))
12
+ def inspect *args
13
+ return super.inspect if args.size == 0
14
+ name, params = args[0], args[1] || {}
15
+ validate Docker::API::InvalidParameter, [:size], params
16
+ @connection.get(build_path([name, "json"], params))
15
17
  end
16
18
 
17
- def self.inspect name, params = {}
18
- validate Docker::API::InvalidParameter, [:size], params
19
- connection.get(build_path([name, "json"], params))
19
+ def list params = {}
20
+ validate Docker::API::InvalidParameter, [:all, :limit, :size, :filters], params
21
+ @connection.get(build_path(["json"], params))
20
22
  end
21
23
 
22
- def self.top name, params = {}
24
+ def top name, params = {}
23
25
  validate Docker::API::InvalidParameter, [:ps_args], params
24
- connection.get(build_path([name, "top"], params))
26
+ @connection.get(build_path([name, "top"], params))
25
27
  end
26
28
 
27
- def self.changes name
28
- connection.get(build_path([name, "changes"]))
29
+ def changes name
30
+ @connection.get(build_path([name, "changes"]))
29
31
  end
30
32
 
31
- def self.start name, params = {}
33
+ def start name, params = {}
32
34
  validate Docker::API::InvalidParameter, [:detachKeys], params
33
- connection.post(build_path([name, "start"], params))
35
+ @connection.post(build_path([name, "start"], params))
34
36
  end
35
37
 
36
- def self.stop name, params = {}
38
+ def stop name, params = {}
37
39
  validate Docker::API::InvalidParameter, [:t], params
38
- connection.post(build_path([name, "stop"], params))
40
+ @connection.post(build_path([name, "stop"], params))
39
41
  end
40
42
 
41
- def self.restart name, params = {}
43
+ def restart name, params = {}
42
44
  validate Docker::API::InvalidParameter, [:t], params
43
- connection.post(build_path([name, "restart"], params))
45
+ @connection.post(build_path([name, "restart"], params))
44
46
  end
45
47
 
46
- def self.kill name, params = {}
48
+ def kill name, params = {}
47
49
  validate Docker::API::InvalidParameter, [:signal], params
48
- connection.post(build_path([name, "kill"], params))
50
+ @connection.post(build_path([name, "kill"], params))
49
51
  end
50
52
 
51
- def self.wait name, params = {}
53
+ def wait name, params = {}
52
54
  validate Docker::API::InvalidParameter, [:condition], params
53
- connection.post(build_path([name, "wait"], params))
55
+ @connection.post(build_path([name, "wait"], params))
54
56
  end
55
57
 
56
- def self.update name, body = {}
58
+ def update name, body = {}
57
59
  validate Docker::API::InvalidRequestBody, Docker::API::UpdateBody, body
58
- connection.post(build_path([name, "update"]), body)
60
+ @connection.request(method: :post, path: build_path([name, "update"]), headers: {"Content-Type": "application/json"}, body: body.to_json)
59
61
  end
60
62
 
61
- def self.rename name, params = {}
63
+ def rename name, params = {}
62
64
  validate Docker::API::InvalidParameter, [:name], params
63
- connection.post(build_path([name, "rename"], params))
65
+ @connection.post(build_path([name, "rename"], params))
64
66
  end
65
67
 
66
- def self.resize name, params = {}
68
+ def resize name, params = {}
67
69
  validate Docker::API::InvalidParameter, [:w, :h], params
68
- connection.post(build_path([name, "resize"], params))
70
+ @connection.post(build_path([name, "resize"], params))
69
71
  end
70
72
 
71
- def self.prune params = {}
73
+ def prune params = {}
72
74
  validate Docker::API::InvalidParameter, [:filters], params
73
- connection.post(build_path(["prune"], params))
75
+ @connection.post(build_path(["prune"], params))
74
76
  end
75
77
 
76
- def self.pause name
77
- connection.post(build_path([name, "pause"]))
78
+ def pause name
79
+ @connection.post(build_path([name, "pause"]))
78
80
  end
79
81
 
80
- def self.unpause name
81
- connection.post(build_path([name, "unpause"]))
82
+ def unpause name
83
+ @connection.post(build_path([name, "unpause"]))
82
84
  end
83
85
 
84
- def self.remove name, params = {}
86
+ def remove name, params = {}
85
87
  validate Docker::API::InvalidParameter, [:v, :force, :link], params
86
- connection.delete(build_path([name]))
88
+ @connection.delete(build_path([name]))
87
89
  end
88
90
 
89
- def self.logs name, params = {}
91
+ def logs name, params = {}
90
92
  validate Docker::API::InvalidParameter, [:follow, :stdout, :stderr, :since, :until, :timestamps, :tail], params
91
93
 
92
94
  path = build_path([name, "logs"], params)
93
95
 
94
96
  if params[:follow] == true || params[:follow] == 1
95
- connection.request(method: :get, path: path , response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect })
97
+ @connection.request(method: :get, path: path , response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect })
96
98
  else
97
- connection.get(path)
99
+ @connection.get(path)
98
100
  end
99
101
  end
100
102
 
101
- def self.attach name, params = {}
103
+ def attach name, params = {}
102
104
  validate Docker::API::InvalidParameter, [:detachKeys, :logs, :stream, :stdin, :stdout, :stderr], params
103
- connection.request(method: :post, path: build_path([name, "attach"], params) , response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect })
105
+ @connection.request(method: :post, path: build_path([name, "attach"], params) , response_block: lambda { |chunk, remaining_bytes, total_bytes| puts chunk.inspect })
104
106
  end
105
107
 
106
- def self.create params = {}, body = {}
108
+ def create params = {}, body = {}
107
109
  validate Docker::API::InvalidParameter, [:name], params
108
110
  validate Docker::API::InvalidRequestBody, Docker::API::CreateBody, body
109
- connection.post(build_path(["create"], params), body)
111
+ @connection.request(method: :post, path: build_path(["create"], params), headers: {"Content-Type": "application/json"}, body: body.to_json)
110
112
  end
111
113
 
112
- def self.stats name, params = {}
114
+ def stats name, params = {}
113
115
  validate Docker::API::InvalidParameter, [:stream], params
114
116
  path = build_path([name, "stats"], params)
115
117
 
@@ -117,37 +119,37 @@ module Docker
117
119
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
118
120
  puts chunk
119
121
  end
120
- connection.request(method: :get, path: path , response_block: streamer)
122
+ @connection.request(method: :get, path: path , response_block: streamer)
121
123
  else
122
- connection.get(path)
124
+ @connection.get(path)
123
125
  end
124
126
  end
125
127
 
126
- def self.export name, path = "exported_container"
127
- response = Docker::API::Container.inspect(name)
128
+ def export name, path = "exported_container"
129
+ response = self.inspect(name)
128
130
  if response.status == 200
129
131
  file = File.open(File.expand_path(path), "wb")
130
132
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
131
133
  file.write(chunk)
132
134
  end
133
- response = connection.request(method: :get, path: build_path([name, "export"]) , response_block: streamer)
135
+ response = @connection.request(method: :get, path: build_path([name, "export"]) , response_block: streamer)
134
136
  file.close
135
137
  end
136
138
  response
137
139
  end
138
140
 
139
- def self.archive name, file, params = {}
141
+ def archive name, file, params = {}
140
142
  validate Docker::API::InvalidParameter, [:path, :noOverwriteDirNonDir, :copyUIDGID], params
141
143
 
142
144
  begin # File exists on disk, send it to container
143
145
  file = File.open( File.expand_path( file ) , "r")
144
- response = connection.request(method: :put, path: build_path([name, "archive"], params) , request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
146
+ response = @connection.request(method: :put, path: build_path([name, "archive"], params) , request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
145
147
  file.close
146
148
  rescue Errno::ENOENT # File doesnt exist, get it from container
147
- response = connection.head(build_path([name, "archive"], params))
149
+ response = @connection.head(build_path([name, "archive"], params))
148
150
  if response.status == 200 # file exists in container
149
151
  file = File.open( File.expand_path( file ) , "wb")
150
- response = connection.request(method: :get, path: build_path([name, "archive"], params) , response_block: lambda { |chunk, remaining_bytes, total_bytes| file.write(chunk) })
152
+ response = @connection.request(method: :get, path: build_path([name, "archive"], params) , response_block: lambda { |chunk, remaining_bytes, total_bytes| file.write(chunk) })
151
153
  file.close
152
154
  end
153
155
  end
@@ -1,6 +1,17 @@
1
1
  module Docker
2
2
  module API
3
- class InvalidParameter < StandardError; end
4
- class InvalidRequestBody < StandardError; end
3
+ class ValidationError < StandardError
4
+ def initialize permitted, unpermitted
5
+ super("Unpermitted options found: #{unpermitted.to_s}. Permitted are #{permitted.to_s}")
6
+ end
7
+ end
8
+ class Error < StandardError
9
+ def initialize msg = "Error without specific message"
10
+ super(msg)
11
+ end
12
+ end
13
+
14
+ class InvalidParameter < Docker::API::ValidationError; end
15
+ class InvalidRequestBody < Docker::API::ValidationError; end
5
16
  end
6
17
  end
@@ -0,0 +1,37 @@
1
+ module Docker
2
+ module API
3
+ class Exec < Docker::API::Base
4
+
5
+ def inspect *args
6
+ return super.inspect if args.size == 0
7
+ name = args[0]
8
+ @connection.get("/exec/#{name}/json")
9
+ end
10
+
11
+ def create name, body = {}
12
+ validate Docker::API::InvalidRequestBody, [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], body
13
+ @connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
14
+ end
15
+
16
+ def start name, body = {}
17
+ validate Docker::API::InvalidRequestBody, [:Detach, :Tty], body
18
+
19
+ stream = ""
20
+ response = @connection.request(method: :post,
21
+ path: "/exec/#{name}/start",
22
+ headers: {"Content-Type": "application/json"},
23
+ body: body.to_json,
24
+ response_block: lambda { |chunk, remaining_bytes, total_bytes| stream += chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') }
25
+ )
26
+ response.data.merge!({stream: stream})
27
+ response
28
+ end
29
+
30
+ def resize name, params = {}
31
+ validate Docker::API::InvalidParameter, [:w, :h], params
32
+ @connection.post(build_path("/exec/#{name}/resize", params))
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -7,113 +7,113 @@ module Docker
7
7
  BuildParams = [:dockerfile, :t, :extrahosts, :remote, :q, :nocache, :cachefrom, :pull, :rm, :forcerm, :memory, :memswap, :cpushares, :cpusetcpus, :cpuperiod, :cpuquota, :buildargs, :shmsize, :squash, :labels, :networkmode, :platform, :target, :outputs]
8
8
  class Image < Docker::API::Base
9
9
 
10
- def self.base_path
10
+ def base_path
11
11
  "/images"
12
12
  end
13
13
 
14
- def self.inspect name
15
- connection.get(build_path([name, "json"]))
14
+ def inspect *args
15
+ return super.inspect if args.size == 0
16
+ name = args[0]
17
+ @connection.get(build_path([name, "json"]))
16
18
  end
17
19
 
18
- def self.history name
19
- connection.get(build_path([name, "history"]))
20
+ def history name
21
+ @connection.get(build_path([name, "history"]))
20
22
  end
21
23
 
22
- def self.list params = {}
24
+ def list params = {}
23
25
  validate Docker::API::InvalidParameter, [:all, :filters, :digests], params
24
- connection.get(build_path(["json"], params))
26
+ @connection.get(build_path(["json"], params))
25
27
  end
26
28
 
27
- def self.search params = {}
29
+ def search params = {}
28
30
  validate Docker::API::InvalidParameter, [:term, :limit, :filters], params
29
- connection.get(build_path(["search"], params))
31
+ @connection.get(build_path(["search"], params))
30
32
  end
31
33
 
32
- def self.tag name, params = {}
34
+ def tag name, params = {}
33
35
  validate Docker::API::InvalidParameter, [:repo, :tag], params
34
- connection.post(build_path([name, "tag"], params))
36
+ @connection.post(build_path([name, "tag"], params))
35
37
  end
36
38
 
37
- def self.prune params = {}
39
+ def prune params = {}
38
40
  validate Docker::API::InvalidParameter, [:filters], params
39
- connection.post(build_path(["prune"], params))
41
+ @connection.post(build_path(["prune"], params))
40
42
  end
41
43
 
42
- def self.remove name, params = {}
44
+ def remove name, params = {}
43
45
  validate Docker::API::InvalidParameter, [:force, :noprune], params
44
- connection.delete(build_path([name], params))
46
+ @connection.delete(build_path([name], params))
45
47
  end
46
48
 
47
- def self.export name, path = "exported_image"
49
+ def export name, path = "exported_image"
48
50
  file = File.open("/tmp/exported-image", "wb")
49
51
  streamer = lambda do |chunk, remaining_bytes, total_bytes|
50
52
  file.write(chunk)
51
53
  end
52
- response = connection.request(method: :get, path: build_path([name, "get"]) , response_block: streamer)
54
+ response = @connection.request(method: :get, path: build_path([name, "get"]) , response_block: streamer)
53
55
  file.close
54
56
  response.status == 200 ? FileUtils.mv("/tmp/exported-image", File.expand_path(path)) : FileUtils.rm("/tmp/exported-image")
55
57
  response
56
58
  end
57
59
 
58
- def self.import path, params = {}
60
+ def import path, params = {}
59
61
  validate Docker::API::InvalidParameter, [:quiet], params
60
62
  file = File.open(File.expand_path(path), "r")
61
- response = connection.request(method: :post, path: build_path(["load"], params) , headers: {"Content-Type" => "application/x-tar"}, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
63
+ response = @connection.request(method: :post, path: build_path(["load"], params) , headers: {"Content-Type" => "application/x-tar"}, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
62
64
  file.close
63
65
  response
64
66
  end
65
67
 
66
- def self.push name, params = {}, authentication = {}
68
+ def push name, params = {}, authentication = {}
67
69
  validate Docker::API::InvalidParameter, [:tag], params
68
70
 
69
71
  if authentication.keys.size > 0
70
- auth = Docker::API::System.auth(authentication)
71
- return auth unless [200, 204].include? auth.status
72
- connection.request(method: :post, path: build_path([name, "push"], params), headers: { "X-Registry-Auth" => Base64.encode64(authentication.to_json.to_s).chomp } )
72
+ @connection.request(method: :post, path: build_path([name, "push"], params), headers: { "X-Registry-Auth" => Base64.urlsafe_encode64(authentication.to_json.to_s).chomp } )
73
73
  else
74
- connection.post(build_path([name, "push"], params))
74
+ raise Docker::API::Error.new("Provide authentication parameters to push an image")
75
75
  end
76
76
  end
77
77
 
78
- def self.commit params = {}, body = {}
78
+ def commit params = {}, body = {}
79
79
  validate Docker::API::InvalidParameter, [:container, :repo, :tag, :comment, :author, :pause, :changes], params
80
80
  validate Docker::API::InvalidRequestBody, Docker::API::CommitBody, body
81
- container = Docker::API::Container.inspect(params[:container])
81
+ container = Docker::API::Container.new.inspect(params[:container])
82
82
  return container if [404, 301].include? container.status
83
83
  body = JSON.parse(container.body)["Config"].merge(body)
84
- connection.request(method: :post, path: build_path("/commit", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
84
+ @connection.request(method: :post, path: build_path("/commit", params), headers: {"Content-Type": "application/json"}, body: body.to_json)
85
85
  end
86
86
 
87
- def self.create params = {}, authentication = {}
87
+ def create params = {}, authentication = {}
88
88
  validate Docker::API::InvalidParameter, [:fromImage, :fromSrc, :repo, :tag, :message, :platform], params
89
89
 
90
90
  if authentication.keys.size > 0
91
- auth = Docker::API::System.auth(authentication)
91
+ auth = Docker::API::System.new.auth(authentication)
92
92
  return auth unless [200, 204].include? auth.status
93
- connection.request(method: :post, path: build_path(["create"], params), headers: { "X-Registry-Auth" => Base64.encode64(authentication.to_json.to_s).chomp } )
93
+ @connection.request(method: :post, path: build_path(["create"], params), headers: { "X-Registry-Auth" => Base64.encode64(authentication.to_json.to_s).chomp } )
94
94
  elsif params.has_key? :fromSrc
95
95
  if params[:fromSrc].match(/^(http|https)/)
96
- connection.request(method: :post, path: build_path(["create"], params))
96
+ @connection.request(method: :post, path: build_path(["create"], params))
97
97
  else
98
98
  file = File.open(File.expand_path(params[:fromSrc]), "r")
99
99
  params[:fromSrc] = "-"
100
- response = connection.request(method: :post, path: build_path(["create"], params) , headers: {"Content-Type" => "application/x-tar"}, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
100
+ response = @connection.request(method: :post, path: build_path(["create"], params) , headers: {"Content-Type" => "application/x-tar"}, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s} )
101
101
  file.close
102
102
  response
103
103
  end
104
104
  else
105
- connection.post(build_path(["create"], params))
105
+ @connection.post(build_path(["create"], params))
106
106
  end
107
107
  end
108
108
 
109
- def self.build path, params = {}, authentication = {}
110
- raise Docker::API::InvalidRequestBody unless path || params[:remote]
109
+ def build path, params = {}, authentication = {}
110
+ raise Docker::API::Error.new("Expected path or params[:remote]") unless path || params[:remote]
111
111
  validate Docker::API::InvalidParameter, Docker::API::BuildParams, params
112
112
 
113
113
  header = {"Content-type": "application/x-tar"}
114
114
  if authentication.keys.size > 0
115
115
  authentication.each_key do |server|
116
- auth = Docker::API::System.auth({username: authentication[server][:username] ,password:authentication[server][:password], serveraddress: server})
116
+ auth = Docker::API::System.new.auth({username: authentication[server][:username] ,password:authentication[server][:password], serveraddress: server})
117
117
  return auth unless [200, 204].include? auth.status
118
118
  end
119
119
  header.merge!({"X-Registry-Config": Base64.urlsafe_encode64(authentication.to_json.to_s).chomp})
@@ -121,17 +121,17 @@ module Docker
121
121
 
122
122
  begin
123
123
  file = File.open( File.expand_path( path ) , "r")
124
- response = connection.request(method: :post, path: build_path("/build", params), headers: header, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s})
124
+ response = @connection.request(method: :post, path: build_path("/build", params), headers: header, request_block: lambda { file.read(Excon.defaults[:chunk_size]).to_s})
125
125
  file.close
126
126
  rescue
127
- response = connection.request(method: :post, path: build_path("/build", params), headers: header)
127
+ response = @connection.request(method: :post, path: build_path("/build", params), headers: header)
128
128
  end
129
129
  response
130
130
  end
131
131
 
132
- def self.delete_cache params = {}
132
+ def delete_cache params = {}
133
133
  validate Docker::API::InvalidParameter, [:all, "keep-storage", :filters], params
134
- connection.post(build_path("/build/prune", params))
134
+ @connection.post(build_path("/build/prune", params))
135
135
  end
136
136
 
137
137
  end