Skip to content

Instantly share code, notes, and snippets.

@jaen
Created September 13, 2018 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaen/7eb284f38d3e410e99ede3bb5131ff04 to your computer and use it in GitHub Desktop.
Save jaen/7eb284f38d3e410e99ede3bb5131ff04 to your computer and use it in GitHub Desktop.
require "JSON"
def get_json(url)
print "Fetching `#{url}`... "
result = `curl -s "#{url}"`
puts "DONE"
JSON.parse(result, :symbolize_names => true)
end
def get_tags(image)
tags = []
url = "https://hub.docker.com/v2/repositories/#{image}/tags/"
while url do
result = get_json(url)
tags += result[:results].map { |result| result[:name]}
url = result[:next]
end
tags
end
# eg. gitlab/gitlab-ce
# get_tags("gitlab/gitlab-ce")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment