-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add support for platform parameter in image push #3325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vvoland can you take a look at this?
vvoland
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is red
| ``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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <khushiyant2002@gmail.com>
Signed-off-by: Khushiyant <khushiyant2002@gmail.com>
Signed-off-by: Khushiyant <khushiyant2002@gmail.com>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issue, good point. I'll see towards that.
…tform class; add test for pushing image with platform dict Signed-off-by: Khushiyant <khushiyant2002@gmail.com>
|
@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