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

Commit 731cc04

Browse files
committed
Use docker cli instead of Docker Hub v1 API
Docker Hub v1 API has been removed. See https://www.docker.com/blog/docker-hub-v1-api-deprecation/ Test Plan: ``` $ python3 test.py Test.test_should_run . ---------------------------------------------------------------------- Ran 1 test in 10.634s OK ```
1 parent d332ae2 commit 731cc04

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

aws/hhvm1/lambdas/activities.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from urllib import request
1010

1111
import common
12-
12+
import subprocess
1313

1414
class Activity:
1515
# Subclasses must override these.
@@ -228,20 +228,18 @@ class PublishDockerImages(Activity):
228228
def task_env(self):
229229
return {'DOCKER_ONLY': '1'}
230230

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

241239
def should_run(self):
242240
return (
243-
self.version() not in self.docker_tags('hhvm') or
244-
self.version() not in self.docker_tags('hhvm-proxygen')
241+
self.is_docker_tag_absent('hhvm') or
242+
self.is_docker_tag_absent('hhvm-proxygen')
245243
)
246244

247245

aws/hhvm1/lambdas/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def test_ec2_params(self):
286286
)
287287

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

292292
self.assertEqual(

0 commit comments

Comments
 (0)