fix(plan): make stop operation formatting consistent and do not count it as removal in summary

This commit is contained in:
Pasha Sviderski
2026-11-03 12:54:57 +10:00
parent ff6ac45e1e
commit 6c7ddeb82f
8 changed files with 48 additions and 5 deletions
+4 -3
View File
@@ -82,7 +82,9 @@ func (o *RunContainerOperation) String() string {
// StopContainerOperation stops a container on a specific machine.
type StopContainerOperation struct {
ServiceID string
ServiceID string
// ServiceName is used for formatting the operation as part of the deployment plan.
ServiceName string
ContainerID string
MachineID string
// MachineName is used for formatting the operation as part of the deployment plan.
@@ -98,8 +100,7 @@ func (o *StopContainerOperation) Execute(ctx context.Context, cli Client) error
}
func (o *StopContainerOperation) Format() string {
// TODO: pass service name to format the display name consistently with other operations.
displayName := stringid.TruncateID(o.ContainerID)
displayName := o.ServiceName + tui.Faint.Render("/") + stringid.TruncateID(o.ContainerID)
return tui.BoldRed.Render("-") + " " +
tui.Faint.Render("stop container") + " " +
+13
View File
@@ -5,6 +5,7 @@ import (
"errors"
"testing"
"github.com/charmbracelet/x/ansi"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/volume"
"github.com/psviderski/uncloud/pkg/api"
@@ -12,6 +13,18 @@ import (
"github.com/stretchr/testify/require"
)
func TestStopContainerOperation_Format(t *testing.T) {
t.Parallel()
op := &StopContainerOperation{
ServiceName: "app",
ContainerID: "0f6df6593e1b0123456789abcdef",
MachineName: "machine-1",
}
assert.Equal(t, "- stop container app/0f6df6593e1b on machine-1", ansi.Strip(op.Format()))
}
func TestReplaceContainerOperation_StopFirstPreparation(t *testing.T) {
t.Parallel()