Skip to content

Commit

Permalink
deprecate MultiStageBuild
Browse files Browse the repository at this point in the history
  • Loading branch information
dcermak committed Aug 23, 2024
1 parent ba95036 commit 8b4579b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Breaking changes:
- change type of ``OciRuntimeBase.build_command`` from ``List[str]`` to
``Tuple[str, ...]``

- deprecate :py:class:`~pytest_container.build.MultiStageBuild` in favor
:py:class:`~pytest_container.container.MultiStageContainer`


Improvements and new features:

Expand Down
19 changes: 19 additions & 0 deletions pytest_container/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
builds via :py:class:`MultiStageBuild`.
"""
import sys
import tempfile
from dataclasses import dataclass
from os.path import basename
Expand All @@ -18,13 +19,19 @@

from _pytest.config import Config
from _pytest.mark.structures import ParameterSet
from deprecation import deprecated
from pytest_container.container import Container
from pytest_container.container import container_and_marks_from_pytest_param
from pytest_container.container import DerivedContainer
from pytest_container.logging import _logger
from pytest_container.runtime import OciRuntimeBase
from pytest_container.runtime import ToParamMixin

if sys.version_info >= (3, 8):
from importlib import metadata
else:
import importlib_metadata as metadata


@dataclass(frozen=True)
class GitRepositoryBuild(ToParamMixin):
Expand Down Expand Up @@ -83,6 +90,14 @@ def test_command(self) -> str:
return cd_cmd


_deprecated_multi_stage_build_kwargs = {
"deprecated_in": "0.5.0",
"removed_in": "0.6.0",
"current_version": metadata.version("pytest_container"),
"details": "use MultiStageContainer instead",
}


@dataclass
class MultiStageBuild:
"""Helper class to perform multi-stage container builds using the
Expand Down Expand Up @@ -149,6 +164,7 @@ class MultiStageBuild:
]

@property
@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
def containerfile(self) -> str:
"""The rendered :file:`Containerfile` from the template supplied in
:py:attr:`containerfile_template`.
Expand All @@ -165,6 +181,7 @@ def containerfile(self) -> str:
}
)

@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
def prepare_build(
self,
tmp_path: Path,
Expand Down Expand Up @@ -197,6 +214,7 @@ def prepare_build(
containerfile.write(self.containerfile)

@staticmethod
@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
def run_build_step(
tmp_path: Path,
runtime: OciRuntimeBase,
Expand Down Expand Up @@ -233,6 +251,7 @@ def run_build_step(
check_output(cmd)
return runtime.get_image_id_from_iidfile(iidfile)

@deprecated(**_deprecated_multi_stage_build_kwargs) # type: ignore
def build(
self,
tmp_path: Path,
Expand Down

0 comments on commit 8b4579b

Please sign in to comment.