Skip to content

Commit

Permalink
Keep image types synced with formats
Browse files Browse the repository at this point in the history
The format is basically the file extension, and for each image type
there should be only one format. The exception here might be docker, as
there might be both tar.xz and tar.gz.
  • Loading branch information
lubomir committed Mar 5, 2019
1 parent fe20b82 commit 5ce2a4d
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions productmd/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,58 @@
from productmd.composeinfo import Compose

from collections import namedtuple
from itertools import chain
import six


__all__ = (
"Image",
"Images",
"IMAGE_TYPE_FORMAT_MAPPING"
"SUPPORTED_IMAGE_TYPES",
"SUPPORTED_IMAGE_FORMATS",
"UNIQUE_IMAGE_ATTRIBUTES",
"UniqueImage",
)

IMAGE_TYPE_FORMAT_MAPPING = {
'boot': ['iso'],
'cd': ['iso'],
'docker': ['tar.gz', 'tar.xz'],
'dvd': ['iso'],
# Usually non-bootable image which contains a repo with debuginfo packages.
'dvd-debuginfo': ['iso'],
# installer image that deploys a payload containing an ostree-based
# distribution
'dvd-ostree': ['iso'],
'ec2': [],
'kvm': [],
'live': [],
'liveimg-squashfs': ['liveimg.squashfs'],
'netinst': ['iso'],
'p2v': [],
'qcow': ['qcow'],
'qcow2': ['qcow2'],
'raw': ['raw'],
'raw-xz': ['raw.xz'],
'rescue': [],
'rhevm-ova': ['rhevm.ova'],
'tar-gz': ['tar.gz'],
'vagrant-hyperv': ['vagrant-hyperv.box'],
'vagrant-libvirt': ['vabrant-libvirt.box'],

This comment has been minimized.

Copy link
@AdamWill

AdamWill Mar 9, 2019

Contributor

this is a straight-up typo.

This comment has been minimized.

Copy link
@lubomir

lubomir Mar 11, 2019

Author Contributor

Yup :( I'll fix it

'vagrant-virtualbox': ['vagrant-virtualbox.box'],
'vagrant-vmware-fusion': ['vagrant-vmware-fusion.box'],
'vdi': ['vdi'],
'vmdk': ['vmdk'],
'vpc': ['vpc'],
'vsphere-ova': ['vsphere.ova'],
}

#: supported image types
SUPPORTED_IMAGE_TYPES = ['boot', 'cd', 'docker', 'dvd',
# Usually non-bootable image which contains a repo
# with debuginfo packages.
'dvd-debuginfo',
# installer image that deploys a payload containing an
# ostree-based distribution
'dvd-ostree',
'ec2', 'kvm', 'live', 'netinst', 'p2v', 'qcow2', 'raw-xz',
'rescue', 'rhevm-ova', 'vagrant-libvirt', 'vagrant-virtualbox',
'vpc', 'vsphere-ova']
SUPPORTED_IMAGE_TYPES = list(sorted(IMAGE_TYPE_FORMAT_MAPPING.keys()))

#: supported image formats, they match with file suffix
SUPPORTED_IMAGE_FORMATS = ['iso', 'qcow', 'qcow2', 'raw', 'raw.xz', 'rhevm.ova',
'sda.raw', 'tar.gz', 'tar.xz', 'vagrant-libvirt.box', 'vagrant-virtualbox.box',
'vdi', 'vhd', 'vmdk', 'vmx', 'vsphere.ova']
SUPPORTED_IMAGE_FORMATS = list(sorted(set(chain(*IMAGE_TYPE_FORMAT_MAPPING.values()))))

#: combination of attributes which uniquely identifies an image across composes
UNIQUE_IMAGE_ATTRIBUTES = [
Expand Down

5 comments on commit 5ce2a4d

@AdamWill
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this make tar-gz both a type and a format? That doesn't seem correct. It also messes with fedfind's attempt to discern the attributes of pre-pungi 4 images by parsing their filenames, because now 'tar-gz' is a valid type, it decides docker images have type 'tar-gz'...I will have to work around this...

@lubomir
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why does this make tar-gz both a type and a format?

It doesn't: tar-gz is type, tar.gz is format. The list is updated to contain everything that Pungi (or koji, really) can create, and that contained tar-gz.

@AdamWill
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this make tar-gz both a type and a format?

It doesn't: tar-gz is type, tar.gz is format. The list is updated to contain everything that Pungi (or koji, really) can create, and that contained tar-gz.

Well, close enough =) Point being, anyway, tar-gz doesn't "smell" like a type at all. It tells you the file is a gzip-compressed tarball. It tells you nothing at all about what it's for. I guess I'll have to go digging in pungi/koji and see if I can find out what the purpose of this thing is...

@lubomir
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pungi really only gives the value to koji, which passes it to image-factory I think. The relevant CLI command is koji image-build.

@AdamWill
Copy link
Contributor

Choose a reason for hiding this comment

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

well, for the record it seems this is basically a raw disk image with a magic name (disk.raw) stuffed in a tarball and gzipped. The purpose of this appears to be that it's the format Google Compute Engine wants for disk image imports (I have no idea why they decided this was a sensible choice, but hey).

I don't think tar-gz is a very good 'type' name for this at all, but we probably can't change it at this point. :(

Please sign in to comment.