Browse Source

Merge "image-uploader: allow an image without Labels to be uploaded" into stable/stein

changes/84/700984/1
Zuul 1 month ago
parent
commit
6ecc782be1
2 changed files with 45 additions and 2 deletions
  1. +2
    -2
      tripleo_common/image/image_uploader.py
  2. +43
    -0
      tripleo_common/tests/image/test_image_uploader.py

+ 2
- 2
tripleo_common/image/image_uploader.py View File

@@ -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 {

+ 43
- 0
tripleo_common/tests/image/test_image_uploader.py View File

@@ -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…
Cancel
Save