Class: Docker::Container

Inherits:
Object
  • Object
show all
Defined in:
lib/drydock/docker_api_patch.rb

Instance Method Summary collapse

Instance Method Details

#archive_get(path = '/', &blk) ⇒ Object



28
29
30
31
32
# File 'lib/drydock/docker_api_patch.rb', line 28

def archive_get(path = '/', &blk)
  query = { 'path' => path }
  connection.get(path_for(:archive), query, response_block: blk)
  self
end

#archive_head(path = '/', &blk) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/drydock/docker_api_patch.rb', line 34

def archive_head(path = '/', &blk)
  query = { 'path' => path }
  response = connection.raw_request(:head, path_for(:archive), query, response_block: blk)

  return if response.nil?
  return if response.headers.empty?
  return unless response.headers.key?('X-Docker-Container-Path-Stat')

  ContainerPathStat.new(response.headers['X-Docker-Container-Path-Stat'])
rescue Docker::Error::NotFoundError
  nil
end

#archive_put(path = '/', overwrite: false, &blk) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/drydock/docker_api_patch.rb', line 47

def archive_put(path = '/', overwrite: false, &blk)
  headers = { 'Content-Type' => 'application/x-tar' }
  query   = { 'path' => path, 'noOverwriteDirNonDir' => overwrite }

  output = StringIO.new
  blk.call(output)
  output.rewind

  connection.put(path_for(:archive), query, headers: headers, body: output)
  self
end