Add support to fetch_wheels for saved images
Change-Id: I622d75d3832c2c5312d6dbdb6c432100484dce17
This commit is contained in:
parent
cf9ad64f3b
commit
9b1daf3a56
|
@ -68,26 +68,37 @@ def parse_image(full_image):
|
||||||
else:
|
else:
|
||||||
return None, image, tag
|
return None, image, tag
|
||||||
|
|
||||||
if 'WHEELS' in os.environ:
|
|
||||||
wheels = os.environ['WHEELS']
|
|
||||||
else:
|
|
||||||
with open('/opt/loci/wheels', 'ro') as f:
|
|
||||||
wheels = f.read()
|
|
||||||
|
|
||||||
with open('/opt/loci/wheels', 'w+') as f:
|
def main():
|
||||||
f.write(wheels)
|
if 'WHEELS' in os.environ:
|
||||||
|
wheels = os.environ['WHEELS']
|
||||||
if wheels.startswith('http'):
|
|
||||||
data = get_wheels(wheels)
|
|
||||||
else:
|
|
||||||
registry, image, tag = parse_image(wheels)
|
|
||||||
kwargs = dict()
|
|
||||||
if registry:
|
|
||||||
kwargs.update({'registry': registry})
|
|
||||||
else:
|
else:
|
||||||
kwargs.update({'token': get_token(image)})
|
with open('/opt/loci/wheels', 'ro') as f:
|
||||||
print(kwargs)
|
wheels = f.read()
|
||||||
data = get_blob(image, tag, **kwargs)
|
|
||||||
|
|
||||||
with open('/tmp/wheels.tar.gz', 'wb') as f:
|
if wheels.startswith('/'):
|
||||||
f.write(data)
|
with open(wheels, 'r') as f:
|
||||||
|
data = f.read()
|
||||||
|
elif wheels.startswith('http'):
|
||||||
|
data = get_wheels(wheels)
|
||||||
|
else:
|
||||||
|
registry, image, tag = parse_image(wheels)
|
||||||
|
kwargs = dict()
|
||||||
|
if registry:
|
||||||
|
kwargs.update({'registry': registry})
|
||||||
|
else:
|
||||||
|
kwargs.update({'token': get_token(image)})
|
||||||
|
data = get_blob(image, tag, **kwargs)
|
||||||
|
|
||||||
|
if 'WHEELS_DEST' in os.environ:
|
||||||
|
dest = os.environ['WHEELS_DEST']
|
||||||
|
else:
|
||||||
|
with open('/opt/loci/wheels', 'w') as f:
|
||||||
|
f.write(wheels)
|
||||||
|
dest = '/tmp/wheels.tar.gz'
|
||||||
|
with open(dest, 'wb') as f:
|
||||||
|
f.write(data)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
Loading…
Reference in New Issue