Skip to content
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

Plugin support to map image to downloadable url #1090

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukaszachy
Copy link
Collaborator

Should be opened to other archictectures and formats.
Modified testcloud to use it for x86_64 and box|qcow2 which are
currently supported (non-intel arch support is work in progress)

Should be opened to other archictectures and formats.
Modified testcloud to use it for x86_64 and box|qcow2 which are
currently supported (non-intel arch support is work in progress)
@lukaszachy
Copy link
Collaborator Author

I went with flow: Get all mapping plugins, call first one's convert for value. If it returns None, try next plugin. If returns string, use it as URL. Each plugin should make sure to return None as soon as possible (e.g. wrong arch, wrong type, wrong name).

What I'm not sure about guidance what to do when plugin should be able to map image value but can't. (e.g. image is nightly compose which has been removed). Should plugin raise GeneralError or return None and let some other plugin map it?

Signature convert(value, arch, format) should accommodate future arch additions (e.g. nightly composes have all archs available so single plugin should be able to handle all arches). I believe we have 3 values for format as of now:
'qcow2' or 'box' for testcloud, 'podman' for podman (this name should be changed imho, what about 'oci'?)

Copy link
Collaborator

@psss psss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general looks good to me. A couple of minor comments added. I'm also thinking about our recent discussion to provide a way for "consistent" image names. Is that something that should be handled around here? Or is this a different topic? Quick braindump of possible usage:

image = tmt.Image("rhel8")
image = tmt.Image("rhel-8")
image = tmt.Image("RHEL8")

Also what are the expectation around the other proposed formats?

rhel-8.nightly (bleeding edge)
rhel-8.tagged (tested by rtt)
rhel-8.tested (how exactly tested?)
rhel-8.latest (what exactly is latest? released? tagged? nightly?)

Plus specifying minor version:

rhel-8.6
rhel-8.6.z

Should everything from above be handled by Image2URLConvertor classes?

Also what about the possibily to choose the output format?

image = tmt.Image("centos-8")
image.url()                 # return url for image download
image.container_image()     # appropriate podman image name (centos:stream8)

Probably will need some more discussion & brainstorming?

name, arch='x86_64', format=[
'box', 'qcow2'])
if url is not None:
return url
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition not needed. The url would be returned even if None because of line 381.

class Image2URLConvertor(object):
""" Common parent for image to url conversion plugins """
@staticmethod
def convert(value, arch=None, format=[]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def convert(value, arch=None, format=[]):
def convert(value, arch=None, format=None):

Using empty list as the default value is not recommended as it can cause problem with repeated calls. See also d4f41a5.

raise NotImplementedError()


def get_image_url(value, arch, format):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value sounds very generic. Is it rather an image name?

@lukaszachy
Copy link
Collaborator Author

I'll update PR with tmt.Image proposal - This class will be layer between user input and provision plugin.
First version will cover only name -> url to qcow2/box

Later we can add 'generic name' support which will do translation generic name -> name -> url to qcow2/box

@lukaszachy lukaszachy marked this pull request as draft March 15, 2022 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants