• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pantsbuild / pants / 21374897774

26 Jan 2026 09:37PM UTC coverage: 80.008% (-0.3%) from 80.269%
21374897774

Pull #23037

github

web-flow
Merge 4023b9eee into 09b8ecaa1
Pull Request #23037: Enable publish without package 2

105 of 178 new or added lines in 11 files covered. (58.99%)

238 existing lines in 14 files now uncovered.

78628 of 98275 relevant lines covered (80.01%)

3.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.36
/src/python/pants/backend/docker/package_types.py
1
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
2
# Licensed under the Apache License, Version 2.0 (see LICENSE).
3

4
from __future__ import annotations
10✔
5

6
from dataclasses import dataclass
10✔
7
from enum import StrEnum, auto
10✔
8

9
from pants.core.goals.package import BuiltPackageArtifact
10✔
10
from pants.engine.addresses import Address
10✔
11
from pants.util.strutil import bullet_list, pluralize
10✔
12

13

14
class DockerPushOnPackageBehavior(StrEnum):
10✔
15
    """Controls whether Docker images can push to registries during packaging."""
16

17
    ALLOW = auto()
10✔
18
    IGNORE = auto()
10✔
19
    WARN = auto()
10✔
20
    ERROR = auto()
10✔
21

22

23
class DockerPushOnPackageException(Exception):
10✔
24
    """Exception raised when a Docker image would push but push behavior is ERROR."""
25

26
    def __init__(self, address: Address):
10✔
NEW
27
        super().__init__(
×
28
            f"The docker_image target {address} would push to a registry but "
29
            f'`[docker].push_on_package` is set to "error".'
30
        )
31

32

33
@dataclass(frozen=True)
10✔
34
class BuiltDockerImage(BuiltPackageArtifact):
10✔
35
    # We don't really want a default for this field, but the superclass has a field with
36
    # a default, so all subsequent fields must have one too. The `create()` method below
37
    # will ensure that this field is properly populated in practice.
38
    image_id: str = ""
10✔
39
    tags: tuple[str, ...] = ()
10✔
40

41
    @classmethod
10✔
42
    def create(
10✔
43
        cls, image_id: str, tags: tuple[str, ...], metadata_filename: str
44
    ) -> BuiltDockerImage:
UNCOV
45
        tags_string = tags[0] if len(tags) == 1 else f"\n{bullet_list(tags)}"
×
UNCOV
46
        return cls(
×
47
            image_id=image_id,
48
            tags=tags,
49
            relpath=metadata_filename,
50
            extra_log_lines=(
51
                f"Built docker {pluralize(len(tags), 'image', False)}: {tags_string}",
52
                f"Docker image ID: {image_id}",
53
            ),
54
        )
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc