Skip to content

Commit

Permalink
Merge pull request #217 from dhodovsk/quick-fix
Browse files Browse the repository at this point in the history
Add recently added parameters also to s2i image class
  • Loading branch information
TomasTomecek authored May 24, 2018
2 parents 3dd9575 + 2ebb0b9 commit ca2dcbc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
3 changes: 3 additions & 0 deletions conu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

from conu.version import __version__ as version # `conu.version == "3.1.4"` should work as well

# enumerations
from conu.apidefs.backend import CleanupPolicy

# PEP-396
# https://www.python.org/dev/peps/pep-0396/
__version__ = version
27 changes: 18 additions & 9 deletions conu/backend/docker/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,42 +458,51 @@ def build(cls, path, tag=None, dockerfile=None):

return cls(None, identifier=image_id)

def get_layer_ids(self, reversed=True):
def get_layer_ids(self, rev=True):
"""
Get IDs of image layers
:param reversed: get layers reversed
:param rev: get layers reversed
:return: list of strings
"""
layers = [x['Id'] for x in self.d.history(self.get_id())]
if not reversed:
l = layers.reverse()
if not rev:
layers = layers.reverse()
return layers

def layers(self, reversed=True):
def layers(self, rev=True):
"""
Get list of DockerImage for every layer in image
:param reversed: get layers reversed
:param rev: get layers rev
:return: list of DockerImages
"""
image_layers = [
DockerImage(None, identifier=x, pull_policy=DockerImagePullPolicy.NEVER)
for x in self.get_layer_ids()
]
if not reversed:
if not rev:
image_layers.reverse()
return image_layers


class S2IDockerImage(DockerImage, S2Image):
def __init__(self, repository, tag="latest"):
def __init__(self, repository, tag="latest", identifier=None,
pull_policy=DockerImagePullPolicy.IF_NOT_PRESENT,
short_metadata=None):
"""
:param repository: str, image name, examples: "fedora", "registry.fedoraproject.org/fedora",
"tomastomecek/sen", "docker.io/tomastomecek/sen"
:param tag: str, tag of the image, when not specified, "latest" is implied
:param identifier: str, unique identifier for this image
:param pull_policy: enum, strategy to apply for pulling the image
:param short_metadata: dict, metadata obtained from `docker.APIClient.images()`
"""
super(S2IDockerImage, self).__init__(repository, tag=tag)
super(S2IDockerImage, self).__init__(repository,
tag=tag,
identifier=identifier,
pull_policy=pull_policy,
short_metadata=short_metadata)
self._s2i_exists = None

def _s2i_command(self, args):
Expand Down

0 comments on commit ca2dcbc

Please sign in to comment.