Hi, can somebody help me with tagging docker image...
# general
a
Hi, can somebody help me with tagging docker images? I tried to follow the documentation and worked out a plugin by trail and error. The goal is to have the image tagged as "latest" and a version determined by our git-versioning-script. When I run "pants package" it works as intended and I get my two tagged immages. But when I run "pants package" the push fails with this error message: "docker push" requires exactly 1 argument." I think that I didnt really understand the plugin system in the right way and am doing it wrong. This is my current plugin-script
Copy code
import logging
from dataclasses import asdict, dataclass

from pants.backend.docker.goals.package_image import DockerFieldSet
from pants.backend.docker.target_types import DockerImageTagsField
from pants.core.goals.package import PackageFieldSet
from pants.engine.rules import collect_rules, rule
from pants.engine.unions import UnionRule

from python_plugins.custom_setup_py import determine_version_from_git

logger = logging.getLogger(__name__)


@dataclass(frozen=True)
class CustomDockerFieldSet(DockerFieldSet):
    ...


@rule
async def custom_docker_tags(request: CustomDockerFieldSet) -> DockerFieldSet:
    version = determine_version_from_git(
        package_name=request.address.target_name,
        build_file_path=request.address.spec_path
    )
    return DockerFieldSet(
        **{
            **asdict(request),
            'tags': DockerImageTagsField(
                raw_value=[
                    # 'latest',
                    str(version)
                ],
                address=request.address
            )
        }
    )


def rules():
    return [
        *collect_rules(),
        UnionRule(PackageFieldSet, CustomDockerFieldSet),
    ]
c
That is a know bug, and will be backported to 2.8.1. If you can try with the latest 2.9.0rc3 it should work. :)
a
wow. cool thank you very much
Just tested it. It works. Thank you so much. 🙂
❤️ 2