From e7e03012823f0ee3c1a2f71a8271bce6f1277be6 Mon Sep 17 00:00:00 2001 From: Andreas Stenius Date: Sat, 29 Jan 2022 23:44:15 +0100 Subject: [PATCH] Graduate Docker backend from experimental status. (#14310) The Docker backend was introduced in Pantsbuild 2.7.0. It is now proven to be a functional backend for many common Docker use cases. This deprecates `pants.backend.experimental.docker` in favour of `pants.backend.docker`. --- .../bin/_generate_all_lockfiles_helper.py | 2 +- build-support/bin/generate_docs.py | 2 +- pants.toml | 2 +- .../goals/run_image_integration_test.py | 2 +- src/python/pants/backend/docker/register.py | 21 +++++++++++++++++++ .../backend/experimental/docker/register.py | 20 +++++++----------- src/python/pants/init/BUILD | 1 + 7 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 src/python/pants/backend/docker/register.py diff --git a/build-support/bin/_generate_all_lockfiles_helper.py b/build-support/bin/_generate_all_lockfiles_helper.py index 199f3a72449..cdc9d46a428 100644 --- a/build-support/bin/_generate_all_lockfiles_helper.py +++ b/build-support/bin/_generate_all_lockfiles_helper.py @@ -109,7 +109,7 @@ def jvm(cls, tool: type[JvmToolBase], *, backend: str | None = None) -> DefaultT DefaultTool.python(PyTest), DefaultTool.python(CoverageSubsystem), DefaultTool.python(TerraformHcl2Parser, backend="pants.backend.experimental.terraform"), - DefaultTool.python(DockerfileParser, backend="pants.backend.experimental.docker"), + DefaultTool.python(DockerfileParser, backend="pants.backend.docker"), DefaultTool.python(TwineSubsystem), # JVM DefaultTool.jvm(JUnit), diff --git a/build-support/bin/generate_docs.py b/build-support/bin/generate_docs.py index fe80a1a28bf..4b5d0a21af1 100644 --- a/build-support/bin/generate_docs.py +++ b/build-support/bin/generate_docs.py @@ -203,8 +203,8 @@ def run_pants_help_all() -> dict[str, Any]: backends = [ "pants.backend.awslambda.python", "pants.backend.codegen.protobuf.python", + "pants.backend.docker", "pants.backend.experimental.codegen.thrift.apache.python", - "pants.backend.experimental.docker", "pants.backend.experimental.docker.lint.hadolint", "pants.backend.experimental.go", "pants.backend.experimental.java", diff --git a/pants.toml b/pants.toml index bab0009b946..5a928bfea25 100644 --- a/pants.toml +++ b/pants.toml @@ -15,7 +15,7 @@ backend_packages.add = [ "pants.backend.shell", "pants.backend.shell.lint.shellcheck", "pants.backend.shell.lint.shfmt", - "pants.backend.experimental.docker", + "pants.backend.docker", "pants.backend.experimental.docker.lint.hadolint", "pants.backend.experimental.go", "pants.backend.experimental.java", diff --git a/src/python/pants/backend/docker/goals/run_image_integration_test.py b/src/python/pants/backend/docker/goals/run_image_integration_test.py index b39925fd71d..614d62306d9 100644 --- a/src/python/pants/backend/docker/goals/run_image_integration_test.py +++ b/src/python/pants/backend/docker/goals/run_image_integration_test.py @@ -12,7 +12,7 @@ def run_pants_with_sources(sources: dict[str, str], *args: str) -> PantsResult: with setup_tmpdir(sources) as tmpdir: return run_pants( [ - "--backend-packages=pants.backend.experimental.docker", + "--backend-packages=pants.backend.docker", "--pants-ignore=__pycache__", ] + [arg.format(tmpdir=tmpdir) for arg in args] diff --git a/src/python/pants/backend/docker/register.py b/src/python/pants/backend/docker/register.py new file mode 100644 index 00000000000..9926e02d13e --- /dev/null +++ b/src/python/pants/backend/docker/register.py @@ -0,0 +1,21 @@ +# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). +# Licensed under the Apache License, Version 2.0 (see LICENSE). + +from pants.backend.codegen import export_codegen_goal +from pants.backend.docker.goals.tailor import rules as tailor_rules +from pants.backend.docker.rules import rules as docker_rules +from pants.backend.docker.target_types import DockerImageTarget +from pants.backend.python.util_rules.pex import rules as pex_rules + + +def rules(): + return ( + *docker_rules(), + *export_codegen_goal.rules(), + *pex_rules(), + *tailor_rules(), + ) + + +def target_types(): + return (DockerImageTarget,) diff --git a/src/python/pants/backend/experimental/docker/register.py b/src/python/pants/backend/experimental/docker/register.py index f7220b6826a..7ef0bb19f24 100644 --- a/src/python/pants/backend/experimental/docker/register.py +++ b/src/python/pants/backend/experimental/docker/register.py @@ -1,21 +1,17 @@ # Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). # Licensed under the Apache License, Version 2.0 (see LICENSE). -from pants.backend.codegen import export_codegen_goal -from pants.backend.docker.goals.tailor import rules as tailor_rules -from pants.backend.docker.rules import rules as docker_rules -from pants.backend.docker.target_types import DockerImageTarget -from pants.backend.python.util_rules.pex import rules as pex_rules +from pants.backend.docker import register +from pants.base.deprecated import deprecated +@deprecated( + "2.11.0.dev0", + "The `pants.backend.experimental.docker` backend has graduated. Use `pants.backend.docker` instead.", +) def rules(): - return ( - *docker_rules(), - *export_codegen_goal.rules(), - *pex_rules(), - *tailor_rules(), - ) + return register.rules() def target_types(): - return (DockerImageTarget,) + return register.target_types() diff --git a/src/python/pants/init/BUILD b/src/python/pants/init/BUILD index 7020aae1dc6..b73ef2ae971 100644 --- a/src/python/pants/init/BUILD +++ b/src/python/pants/init/BUILD @@ -9,6 +9,7 @@ target( dependencies=[ "src/python/pants/backend/awslambda/python", "src/python/pants/backend/codegen/protobuf/python", + "src/python/pants/backend/docker", "src/python/pants/backend/experimental/codegen/avro/java", "src/python/pants/backend/experimental/codegen/protobuf/java", "src/python/pants/backend/experimental/codegen/protobuf/scala",