kiwi.oci_tools

 1# Copyright (c) 2018 SUSE Linux GmbH.  All rights reserved.
 2#
 3# This file is part of kiwi.
 4#
 5# kiwi is free software: you can redistribute it and/or modify
 6# it under the terms of the GNU General Public License as published by
 7# the Free Software Foundation, either version 3 of the License, or
 8# (at your option) any later version.
 9#
10# kiwi is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with kiwi.  If not, see <http://www.gnu.org/licenses/>
17#
18from abc import (
19    ABCMeta,
20    abstractmethod
21)
22from kiwi.oci_tools.base import OCIBase
23
24# project
25from kiwi.runtime_config import RuntimeConfig
26from kiwi.exceptions import (
27    KiwiOCIArchiveToolError
28)
29
30
31class OCI(metaclass=ABCMeta):
32    """
33    **OCI Factory**
34    """
35    @abstractmethod
36    def __init__(self) -> None:
37        return None  # pragma: no cover
38
39    @staticmethod
40    def new() -> OCIBase:
41        tool_name = RuntimeConfig().get_oci_archive_tool()
42        if tool_name == "umoci":
43            from kiwi.oci_tools.umoci import OCIUmoci
44            return OCIUmoci()
45        elif tool_name == "buildah":
46            from kiwi.oci_tools.buildah import OCIBuildah
47            return OCIBuildah()
48        else:
49            raise KiwiOCIArchiveToolError(
50                'No support for {0} tool available'.format(tool_name)
51            )
class OCI:
32class OCI(metaclass=ABCMeta):
33    """
34    **OCI Factory**
35    """
36    @abstractmethod
37    def __init__(self) -> None:
38        return None  # pragma: no cover
39
40    @staticmethod
41    def new() -> OCIBase:
42        tool_name = RuntimeConfig().get_oci_archive_tool()
43        if tool_name == "umoci":
44            from kiwi.oci_tools.umoci import OCIUmoci
45            return OCIUmoci()
46        elif tool_name == "buildah":
47            from kiwi.oci_tools.buildah import OCIBuildah
48            return OCIBuildah()
49        else:
50            raise KiwiOCIArchiveToolError(
51                'No support for {0} tool available'.format(tool_name)
52            )

OCI Factory

@staticmethod
def new() -> kiwi.oci_tools.base.OCIBase:
40    @staticmethod
41    def new() -> OCIBase:
42        tool_name = RuntimeConfig().get_oci_archive_tool()
43        if tool_name == "umoci":
44            from kiwi.oci_tools.umoci import OCIUmoci
45            return OCIUmoci()
46        elif tool_name == "buildah":
47            from kiwi.oci_tools.buildah import OCIBuildah
48            return OCIBuildah()
49        else:
50            raise KiwiOCIArchiveToolError(
51                'No support for {0} tool available'.format(tool_name)
52            )