#! /usr/bin/python3
import json
import urllib.request
urlhead = '10.128.222.245:5000/'
def getTag(image):
requrl = "http://"+urlhead+"/v2/"+image+"/tags/list"
webURL = urllib.request.urlopen(requrl)
#print(webURL.read())
#JSON_object = json.loads(webURL.read()) #this is the line that doesn't work
data = webURL.read()
#print(data)
encoding = webURL.info().get_content_charset('utf-8')
json_data = json.loads(data.decode(encoding))
#print(json_data)
print ( urlhead+ json_data['name']+ ':' + json_data['tags'][0])
requrl = "http://"+urlhead+"/v2/_catalog"
webURL = urllib.request.urlopen(requrl)
data = webURL.read()
#print(data)
encoding = webURL.info().get_content_charset('utf-8')
json_data = json.loads(data.decode(encoding))
#print(json_data)
#print(len(json_data['repositories']))
for element in json_data['repositories']:
#print(element)
getTag(element)