image-uploader: allow an image without Labels to be uploaded
Some images, like grafana don't have Labels set; let's just set an empty default if an image has no Labels and continue the upload. Change-Id: I571af51db0d21226bc42dc21925384f0129cd581 Closes-Bug: #1857012 (cherry picked from commit95b68c6d19
) (cherry picked from commit95f837bf1e
)
This commit is contained in:
parent
13b77d3670
commit
d725569c44
|
@ -646,7 +646,7 @@ class BaseImageUploader(object):
|
|||
name = '%s%s' % (image_url.netloc, image)
|
||||
created = config['created']
|
||||
docker_version = config.get('docker_version', '')
|
||||
labels = config['config']['Labels']
|
||||
labels = config['config'].get('Labels', {})
|
||||
architecture = config['architecture']
|
||||
image_os = config['os']
|
||||
|
||||
|
@ -2110,7 +2110,7 @@ class PythonImageUploader(BaseImageUploader):
|
|||
i, _ = cls._image_tag_from_url(image_url)
|
||||
digest = image['digest']
|
||||
created = image['created']
|
||||
labels = config['config']['Labels']
|
||||
labels = config['config'].get('Labels', {})
|
||||
architecture = config['architecture']
|
||||
image_os = config['os']
|
||||
return {
|
||||
|
|
|
@ -2283,6 +2283,49 @@ class TestPythonImageUploader(base.TestCase):
|
|||
self.uploader._inspect(url)
|
||||
)
|
||||
|
||||
@mock.patch('tripleo_common.image.image_uploader.'
|
||||
'PythonImageUploader._image_manifest_config')
|
||||
def test_inspect_no_labels(self, _image_manifest_config):
|
||||
url = urlparse('containers-storage:/t/nova-api:latest')
|
||||
config = {
|
||||
'config': {},
|
||||
'architecture': 'x86_64',
|
||||
'os': 'linux'
|
||||
}
|
||||
_image_manifest_config.return_value = (
|
||||
{
|
||||
'id': 'cccc',
|
||||
'digest': 'sha256:ccccc',
|
||||
'names': ['192.168.2.1:5000/t/nova-api:latest'],
|
||||
'created': '2018-10-02T11:13:45.567533229Z'
|
||||
}, {
|
||||
'config': {
|
||||
'digest': 'sha256:1234',
|
||||
},
|
||||
'layers': [
|
||||
{'digest': 'sha256:aaa'},
|
||||
{'digest': 'sha256:bbb'},
|
||||
{'digest': 'sha256:ccc'}
|
||||
],
|
||||
},
|
||||
json.dumps(config)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
{
|
||||
'Name': '/t/nova-api',
|
||||
'Architecture': 'x86_64',
|
||||
'Created': '2018-10-02T11:13:45.567533229Z',
|
||||
'Digest': 'sha256:ccccc',
|
||||
'DockerVersion': '',
|
||||
'Labels': {},
|
||||
'Layers': ['sha256:aaa', 'sha256:bbb', 'sha256:ccc'],
|
||||
'Os': 'linux',
|
||||
'RepoTags': []
|
||||
},
|
||||
self.uploader._inspect(url)
|
||||
)
|
||||
|
||||
@mock.patch('os.environ')
|
||||
@mock.patch('subprocess.Popen')
|
||||
def test_delete(self, mock_popen, mock_environ):
|
||||
|
|
Loading…
Reference in New Issue