Skip to content

Commit

Permalink
fix no image yet
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Mar 26, 2024
1 parent 8c2c471 commit c8c2b4a
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions scripts/get_docker_image_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,48 @@
distro = args.dist
#default_distro = args.default_dist

if args.qgis == 'dekstop':
stable = ""
ltr = ""

if args.qgis == 'desktop':
repo_name = 'qgis'
else:
repo_name = 'qgis-server'

url = f'https://registry.hub.docker.com/v2/repositories/qgis/{repo_name}/tags?page_size=10000'
data = requests.get(url).content.decode('utf-8')
tags = json.loads(data)['results']
r = requests.get(url)
if r.status_code == 404:
# the image does not exist yet
pass
else:
data = r.content.decode('utf-8')
tags = json.loads(data)['results']

stable_sha = None
ltr_sha = None
stable_sha = None
ltr_sha = None

# get available tags
availables_tags = dict()
# get available tags
availables_tags = dict()

# get the full version
match = f'^\d\.\d+\.\d+-{distro}$'
# get the full version
match = f'^\d\.\d+\.\d+-{distro}$'

for tag in tags:
if tag['name'] == f'stable-{distro}':
stable_sha = tag['images'][0]['digest'] # sha
elif tag['name'] == f'ltr-{distro}':
ltr_sha = tag['images'][0]['digest'] # sha
elif re.match(match, tag['name']):
availables_tags[tag['name']] = tag['images'][0]['digest']
for tag in tags:
if tag['name'] == f'stable-{distro}':
stable_sha = tag['images'][0]['digest'] # sha
elif tag['name'] == f'ltr-{distro}':
ltr_sha = tag['images'][0]['digest'] # sha
elif re.match(match, tag['name']):
availables_tags[tag['name']] = tag['images'][0]['digest']

# determine what is ltr and stable
stable = ""
ltr = ""
for tag, sha in availables_tags.items():
if sha == stable_sha:
stable = tag
stable = stable.replace(f'-{distro}', '')
elif sha == ltr_sha:
ltr = tag
ltr = ltr.replace(f'-{distro}', '')
# determine what is ltr and stable
for tag, sha in availables_tags.items():
if sha == stable_sha:
stable = tag
stable = stable.replace(f'-{distro}', '')
elif sha == ltr_sha:
ltr = tag
ltr = ltr.replace(f'-{distro}', '')

output = {'stable': stable, 'ltr': ltr}
print(json.dumps(output))

0 comments on commit c8c2b4a

Please sign in to comment.