Class: DockerRegistry
- Inherits:
-
Object
- Object
- DockerRegistry
- Defined in:
- lib/support/docker_registry.rb
Instance Method Summary collapse
- #find_images ⇒ Object
- #find_tags(image_name) ⇒ Object
- #has_image_with_version?(image, commit_id) ⇒ Boolean
- #images_and_versions ⇒ Object
-
#initialize(registry_url) ⇒ DockerRegistry
constructor
A new instance of DockerRegistry.
Constructor Details
#initialize(registry_url) ⇒ DockerRegistry
Returns a new instance of DockerRegistry.
5 6 7 8 9 10 11 |
# File 'lib/support/docker_registry.rb', line 5 def initialize(registry_url) @server = registry_url if (!registry_url.include? "://") registry_url = "https://#{registry_url}" end @connection = connection(registry_url) end |
Instance Method Details
#find_images ⇒ Object
13 14 15 16 17 18 |
# File 'lib/support/docker_registry.rb', line 13 def find_images() response = @connection.get "/v2/_catalog" raise "catalog retrieval return error: #{response.status} #{response.body}" if (response.status != 200) json = JSON.parse(response.body) return json['repositories'] end |
#find_tags(image_name) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/support/docker_registry.rb', line 20 def (image_name) response = @connection.get "/v2/#{image_name}/tags/list" raise "Querying tags returned error code: #{response.status}" if (response.status != 200) json = JSON.parse(response.body) return json['tags'] end |
#has_image_with_version?(image, commit_id) ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/support/docker_registry.rb', line 27 def has_image_with_version?(image, commit_id) = self.(image) if ( != nil) .each do |tag| return true if (tag == commit_id) end end return false end |
#images_and_versions ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/support/docker_registry.rb', line 37 def images_and_versions hash = {} images = find_images() images.each do |image| = (image) hash[image] = end return hash end |