-
Notifications
You must be signed in to change notification settings - Fork 186
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
Adding OCI image and a respective test class #734
Conversation
From what I can tell, circleci only supports ubuntu 1604 hosts for the test and skopeo needs 1804, correct? If this is the case, we should disable circleci tests and only use github actions to run the tests since github hosts use ubuntu 1804 as the default latest linux image. I think we should address this in a separate PR, though. |
In general, some comments in your code would be nice :) This is helpful as we review the PR and also for future contributors. Note that for comments describing the functionality of a function we use the three backticks enclosures ( |
Yes, I checked and it uses 18.04. |
Ok, then let me disable circleci testing. Can you plan to open a separate PR to enable tests for images in the github config file ( |
@rnjudge , can I raise an issue for this change? |
Please! |
Done! Apologies for missing them at first place :) |
@mukultaneja I've triggered rerunning the builds so we will see if all the tests pass in a bit |
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.
@mukultaneja it looks like you've just copied over the functionality in the DockerImage class. The only thing you will need to do in this class is to implement load_image
. Here you will need to look at the tarball created with podman save --format oci-archive -o debian.tar debian:latest
. You can use any extra functions to help with that.
tern/classes/oci_image.py
Outdated
to_dict: return a dict representation of the object | ||
''' | ||
|
||
def __init__(self, repotag=None, image_id=None, image_name=None): |
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 we will have to use repotag here only. I will file an issue for that change to go through first.
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.
The second may be to see if we can use the registry API to get the image. I can look at this further.
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 we will have to use repotag here only. I will file an issue for that change to go through first.
@nishakm I have resolved this comment in the commit.
Could you please give me a little bit idea behind
|
@nishakm I have updated the code and tried to address all the given comments. Now in ths commit,
Please review it once and share your feedback. I have also gone through the example you shared and if I understand it correctly then I think the architecture information is the key here to load the specific manifest. If it is correct then how should we get this information? |
checksum_type = self.get_diff_checksum_type(image_index_data) | ||
while layer_paths: | ||
layer = ImageLayer(None, layer_paths.pop(0)) | ||
layer.set_checksum(checksum_type, layer.diff_id) |
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.
here layer.diff_id
will be None
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.
Turns out, if you are using a tool to convert from a docker image to an OCI image, you may be able to get the layer's diff_id. But in this case, the layer's checksum can be found from the manifest's layers
list.
Hi @mukultaneja, can you try to rebase your commit? I think your build will pass then. Sorry for the delay in replying. |
Following commit adds a class to read OCI images along with tests to validate its functionality. Work towards: #678 Signed-off-by: mukultaneja <[email protected]>
Hi @nishakm, no issues :). I just did rebase my branch and now I am only getting issues for importing missing modules |
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 looks like a couple of file changes are missing from this PR and the tests are referencing unknown modules.
Another thing I have found out from my experiments is that querying the Dockerhub API may get you an OCI image format. I still need to poke at that direction. So I am going to hold off on providing feedback on this PR until I have something concrete for you.
raise NameError("Image object initialized with no repotag") | ||
|
||
# parse the repotag | ||
repo_dict = general.parse_oci_image_string(self._repotag) |
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 guess I am expecting an addition of a function in general.py
?
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
self._name = repo_dict.get('name') | ||
self._tag = repo_dict.get('tag') | ||
self._image_path = repo_dict.get('path') | ||
|
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 what would be better is if this functionality got moved to the Image
class so the DockerImage
class can also take advantage of it.
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, I think self._name
and self._tag
are common so we can move it to Image
class but self._image_path
we have to keep it in oci_image
.
def load_image(self): | ||
'''Load OCI image metadata using manifest''' | ||
try: | ||
# validate OCI iamge's directory layout |
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.
s/iamge's/image's
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.
sure. its a typo. my bad!
'''Load OCI image metadata using manifest''' | ||
try: | ||
# validate OCI iamge's directory layout | ||
helpers.validate_image_path(self.image_path) |
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 you can put this function in here instead of helpers
.
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.
ok. I am neutral to keep it here as well.
checksum_type = self.get_diff_checksum_type(image_index_data) | ||
while layer_paths: | ||
layer = ImageLayer(None, layer_paths.pop(0)) | ||
layer.set_checksum(checksum_type, layer.diff_id) |
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.
Turns out, if you are using a tool to convert from a docker image to an OCI image, you may be able to get the layer's diff_id. But in this case, the layer's checksum can be found from the manifest's layers
list.
@nishakm, I remember last time we discussed that we are not concerned to get |
Sure. Please let me know if I can help with the experiment. Just one thing here to ask, is it going to change the oci image input to |
It probably will in the sense that we don't need |
Following commit adds a class to read OCI images
along with tests to validate its functionality.
Work towards: #678
Signed-off-by: mukultaneja [email protected]