Add support for platform parameter in image push#3325
Add support for platform parameter in image push#3325Khushiyant wants to merge 4 commits intodocker:mainfrom
Conversation
3dd9b4f to
2356a17
Compare
|
Any chance someone can look at this? This causing a bug for me. What happens without this is tags can’t be pushed to registries. Only the sha. Say I copy a docker image from one registry to another. You want to copy a specific platform, then it won’t push the tag without specifying the platform. |
| ``username`` and ``password`` keys to be valid. | ||
| decode (bool): Decode the JSON data from the server into dicts. | ||
| Only applies with ``stream=True`` | ||
| platform (str): JSON-encoded OCI platform to select the platform-variant to push. If not provided, all available variants will attempt to be pushed. |
There was a problem hiding this comment.
It's expected to be a JSON-encoded at the API level. But at the SDK level, it would probably be better if it was an instance of a nicer "Platform" class/struct.
There was a problem hiding this comment.
Whatever the case shouldn’t it match the pull? There shouldn’t be a string in one and class in another.
There was a problem hiding this comment.
No, these have different format. Pull accepts a plain platform string like linux/amd64, but this one is a full JSON representing an OCI platform.
But you're right, that it's inconsistent and we probably should fix it at some point.
There was a problem hiding this comment.
@vvoland can you take a look at this?
| ``username`` and ``password`` keys to be valid. | ||
| decode (bool): Decode the JSON data from the server into dicts. | ||
| Only applies with ``stream=True`` | ||
| platform (str): JSON-encoded OCI platform to select the platform-variant to push. If not provided, all available variants will attempt to be pushed. |
There was a problem hiding this comment.
This should be an instance of the new Platform
docker/api/image.py
Outdated
| raise errors.InvalidVersion( | ||
| 'platform was only introduced in API version 1.46' | ||
| ) | ||
| params['platform'] = Platform |
There was a problem hiding this comment.
Why Platform (class) instead of the platform (instance)`?
| params['platform'] = Platform | |
| params['platform'] = platform |
docker/types/image.py
Outdated
| 'Architecture': architecture, | ||
| 'OS': os, | ||
| 'OSVersion': kwargs.get('os_version', kwargs.get('OSVersion')), | ||
| 'OSFeatures': kwargs.get('os_features', kwargs.get('OSFeatures')), | ||
| 'Variant': kwargs.get('variant', kwargs.get('Variant')) |
There was a problem hiding this comment.
I think this could be lowercase, also I don't think there's the need to support the Titlecased fields.
|
@Khushiyant any progress on this? |
0b58572 to
a4351da
Compare
Signed-off-by: Khushiyant <[email protected]>
Signed-off-by: Khushiyant <[email protected]>
Signed-off-by: Khushiyant <[email protected]>
a4351da to
3f89d1e
Compare
docker/types/image.py
Outdated
| os = kwargs.get('os') | ||
|
|
||
| if architecture is None and os is None: | ||
| raise ValueError("At least one of 'architecture' or 'os' must be provided") |
There was a problem hiding this comment.
This message doesn't match the logic. you are requiring both and not just one. I'd either correct the logic or correct the statement.
There was a problem hiding this comment.
Yeah, this was a leftover from the last changes. I'll fix this.
| ) | ||
|
|
||
| @requires_api_version('1.46') | ||
| def test_push_image_with_platform(self): |
There was a problem hiding this comment.
Not to be picky, but your function can take either Platform OR dict, but you are just testing one.
There was a problem hiding this comment.
No issue, good point. I'll see towards that.
…tform class; add test for pushing image with platform dict Signed-off-by: Khushiyant <[email protected]>
|
@vvoland it looks he did what you asked. |
Closes #3324
Adds the following:
platformparameter handling inimages.api.pushtests/unit/api_image_test.py::ImageTest::test_push_image_with_platform