Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Use docker cli instead of Docker Hub v1 API #318

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions aws/hhvm1/lambdas/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from urllib import request

import common

import subprocess

class Activity:
# Subclasses must override these.
Expand Down Expand Up @@ -228,20 +228,18 @@ class PublishDockerImages(Activity):
def task_env(self):
return {'DOCKER_ONLY': '1'}

def docker_tags(self, repo):
return {
tag['name'] for tag in json.loads(
request
.urlopen(f'https://index.docker.io/v1/repositories/hhvm/{repo}/tags')
.read()
.decode('ascii')
)
}
def is_docker_tag_absent(self, repo):
docker_subprocess = subprocess.run(('docker', 'manifest', 'inspect', f'hhvm/hhvm:{self.version()}'), capture_output=True)
if docker_subprocess.returncode == 1 and docker_subprocess.stderr.startswith(b'no such manifest'):
return True
else:
docker_subprocess.check_returncode()
return False

def should_run(self):
return (
self.version() not in self.docker_tags('hhvm') or
self.version() not in self.docker_tags('hhvm-proxygen')
self.is_docker_tag_absent('hhvm') or
self.is_docker_tag_absent('hhvm-proxygen')
)


Expand Down
2 changes: 1 addition & 1 deletion aws/hhvm1/lambdas/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_ec2_params(self):
)

def test_should_run(self):
past = (date.today() - timedelta(days=2)).strftime('%Y.%m.%d')
past = (date.today() - timedelta(days=42)).strftime('%Y.%m.%d')
future = (date.today() + timedelta(days=2)).strftime('%Y.%m.%d')

self.assertEqual(
Expand Down