Skip to content

Conversation

@erwindouna
Copy link
Contributor

@erwindouna erwindouna commented Jan 2, 2026

Breaking change

Proposed change

Add the functionality per endpoint to prune unused images. In the current implementation this is made available via a button on the endpoint entity.
Later on this can be extended to an Action, so users can use this more freely and create their own automations (i.e.: dangling or not, when to prune based on the until paramater made available via pyportainer).

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

Copilot AI review requested due to automatic review settings January 2, 2026 14:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds functionality to prune unused Docker images at the endpoint level in the Portainer integration. The feature is exposed through a new button entity for each endpoint, allowing users to manually trigger image pruning operations. The PR also improves existing code by adding translation keys for previously hardcoded button names.

Key changes:

  • Adds PortainerEndpointButton entity class for endpoint-level button actions
  • Creates "Prune unused images" button for each Portainer endpoint
  • Migrates existing container restart buttons to use translation keys instead of hardcoded names

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
homeassistant/components/portainer/button.py Adds endpoint button support with new PortainerEndpointButton class, creates ENDPOINT_BUTTONS tuple with images_prune action, renames BUTTONS to CONTAINER_BUTTONS, and adds translation keys for existing buttons
homeassistant/components/portainer/strings.json Adds translation strings for button entities including images_prune, restart_container, and prune_endpoint
tests/components/portainer/test_button.py Adds comprehensive test coverage for endpoint button functionality including success and error scenarios, renames existing test functions for clarity
tests/components/portainer/snapshots/test_button.ambr Updates snapshots to reflect translation key changes and adds snapshot for new prune_unused_images button entity
tests/components/portainer/conftest.py Adds images_prune mock method to the mock Portainer client

@home-assistant home-assistant bot marked this pull request as draft January 2, 2026 15:06
@home-assistant
Copy link

home-assistant bot commented Jan 2, 2026

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@erwindouna erwindouna marked this pull request as ready for review January 2, 2026 15:50
@home-assistant home-assistant bot requested a review from zweckj January 2, 2026 15:50
Copy link
Contributor

@liudger liudger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

translation_domain=DOMAIN,
translation_key="cannot_connect",
translation_placeholders={"error": repr(err)},
translation_placeholders={"error": "See details in logs"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now we'd have the untranslated string "See details in logs" in the UI and still a mix of languages

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see other integrations still having the repr or str method. What do you propose in this scenario to implement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you propose in this scenario to implement?

depends a bit on my next question below. In this case I'd just remove that entirely tbh

I see other integrations still having the repr or str method.

yes, we do have that in the codebase currently, need to clean that up at some point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can leave it empty, but can't fully remove it, since it's defined in the strings.json. Creating a new exception string for this, seems a bit overkill?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's our best best tbh, because looking at the string it's now "something happened: ", which might look confusion to the user

@home-assistant home-assistant bot marked this pull request as draft January 6, 2026 12:09
@erwindouna erwindouna marked this pull request as ready for review January 6, 2026 13:44
@home-assistant home-assistant bot requested a review from zweckj January 6, 2026 13:44
zweckj
zweckj previously approved these changes Jan 6, 2026
@zweckj zweckj dismissed their stale review January 6, 2026 15:02

open comment

@erwindouna
Copy link
Contributor Author

@zweckj exceptions with no details have been added.

@zweckj zweckj merged commit a2ef0c9 into home-assistant:dev Jan 8, 2026
36 checks passed
@erwindouna erwindouna deleted the portainer-add-images-prune branch January 8, 2026 16:07
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants