#510 Convert frequent used image properties to real ContainerImage properties
Closed by mprahl. Opened by cqi.
cqi/freshmaker new-image-properties  into  master

Download 510.patch

An image's name, version and parent are accessed frequently by parsing
from ContainerImage.nvr and key parent. This change proposed a new way
to access these properties by making properties of ContainerImage, e.g.
ContainerImage.name and ContainerImage.parent. With these changes, the
original code becomes shorter and less calls to the function to parse
N-V-R from an image's brew build NVR.

This proposed change removes an interface ContainerImage.create that I
wrote before. After reviewing this piece of code again, I feel it's
useless. Instead, a normal construction just works well. For example to
initiate an image object, the code could be:

image = ContainerImage({'brew': {'build': 'n-v-r'}})

Signed-off-by: Chenxiong Qi cqi@redhat.com

rebased onto 62a44dfaf32ab13cc35e51a229b7ec06471dde91

@cqi there are conflicts, can you fix them?

rebased onto 11fa4e66ff44ef18e8bd25616343b3002e0d83c1

@gnaponie Rebased and fixed the conflicts. PTAL.

dict doesn't accept non-keyworded arguments.

+1 (+ what @qwan said.)

@cqi could you please solve the commits also here? Then we can merge this. Thank you

@cqi ping?

rebased onto 391d8e20df1cd324a9ff818363e12cebe17804a7

rebased onto 7f7737d79a98b2e5c6a97b951f2fd031b6be378d

Sorry for late response. Patch is rebased and conflicts are fixed.

@qwan @jkaluza

The *args is for the case ContainerImage({...}).

rebased onto 5684157faed743de40fd0456b469d0d68c65251f

Tests are fixed.

Can you update this? because dict expect at most one argument, and it can accept either one argument or name=value pairs, but not both.

One minor comment, other looks good to me.

Can you update this? because dict expect at most one argument, and it can accept either one argument or name=value pairs, but not both.

This __init__ inherits the ability of dict to initialize an object in these two ways:

image = ContainerImage({...})
image = ContainerImage(name=.., version=.., ...)

To keep the usage flexible, I'd like to keep this basic ability for ContainerImage as well.

To keep the usage flexible, I'd like to keep this basic ability for ContainerImage as well.

Since both dict.__init__ and dict.update don't accept multiple arguments, it doesn't make sense to have such code. I'd suggest something like:

    def __init__(self, data=None, **kwargs):
        super().__init__(**kwargs)
        if data:
            self.update(data)

minor: I'd remove the '/' between 'brew/build'

Just a minor comment, but it looks good to me +1

Freshmaker has been migrated to GitHub. Please reopen your PR on GitHub.

Pull-Request has been closed by mprahl

Metadata