Class: Docker::Distribution::Api::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/docker/distribution/api/manifest.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, hash = {}) ⇒ Manifest

Returns a new instance of Manifest.



10
11
12
13
14
15
# File 'lib/docker/distribution/api/manifest.rb', line 10

def initialize(connection, hash={})
  unless connection.is_a?(Docker::Distribution::Connection)
    raise ArgumentError, "Expected a Docker::Distribution::Connection, got: #{connection}."
  end
  @connection, @info = connection, hash
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



5
6
7
# File 'lib/docker/distribution/api/manifest.rb', line 5

def connection
  @connection
end

#infoObject

Returns the value of attribute info.



5
6
7
# File 'lib/docker/distribution/api/manifest.rb', line 5

def info
  @info
end

Class Method Details

.get_by_tag(repository, tag, connection = Api.connection) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/docker/distribution/api/manifest.rb', line 26

def self.get_by_tag(repository, tag, connection = Api.connection)
  response = connection.get(
    "/#{repository}/manifests/#{tag}", nil, :headers => {:Accept => 'application/vnd.docker.distribution.manifest.v2+json'}
  )
  manifest_json = Util.parse_json(response.body)
  hash = manifest_json
  hash['digest'] = response.headers['Docker-Content-Digest']
  hash['repository'] = repository
  hash['tag'] = tag
  new(connection, hash)
end

Instance Method Details

#deleteObject



17
18
19
20
21
22
23
24
# File 'lib/docker/distribution/api/manifest.rb', line 17

def delete
  @connection.delete(
    "/#{@info['repository']}/manifests/#{@info['digest']}",
    nil,
    :expects => [202]
  )
  nil
end