refactor: event ID generation for images, machines, and volumes to align with plan formatting

This commit is contained in:
Pasha Sviderski
2026-04-08 19:16:42 +10:00
parent 3e30a59d4c
commit fe813302b7
4 changed files with 24 additions and 4 deletions
+18
View File
@@ -47,3 +47,21 @@ func OldPreDeployHookEventID(serviceName, containerID, machineName string) strin
serviceName + tui.Faint.Render("/") + stringid.TruncateID(containerID) +
tui.Faint.Render(" on ") + machineName
}
// ImageEventID returns a progress event ID for image pull operations.
func ImageEventID(image, machineName string) string {
return tui.Faint.Render("Image ") + image +
tui.Faint.Render(" on ") + machineName
}
// VolumeEventID returns a progress event ID for volume operations.
func VolumeEventID(volumeName, machineName string) string {
return tui.Faint.Render("Volume ") + volumeName +
tui.Faint.Render(" on ") + machineName
}
// MachineEventID returns a progress event ID for machine operations.
func MachineEventID(machineName, publicIP string) string {
return tui.Faint.Render("Machine ") + machineName +
tui.Faint.Render(" (") + publicIP + tui.Faint.Render(")")
}
+1 -1
View File
@@ -131,7 +131,7 @@ func (cli *Client) createServiceContainerWithPull(
func (cli *Client) pullImageWithProgress(ctx context.Context, image, machineName, parentEventID string) error {
pw := progress.ContextWriter(ctx)
eventID := fmt.Sprintf("Image %s on %s", image, machineName)
eventID := cliprogress.ImageEventID(image, machineName)
pw.Event(progress.Event{
ID: eventID,
ParentID: parentEventID,
+2 -1
View File
@@ -13,6 +13,7 @@ import (
"github.com/cenkalti/backoff/v4"
"github.com/docker/compose/v2/pkg/progress"
cliprogress "github.com/psviderski/uncloud/internal/cli/progress"
"github.com/psviderski/uncloud/internal/machine/api/pb"
"github.com/psviderski/uncloud/internal/machine/caddyconfig"
"github.com/psviderski/uncloud/pkg/api"
@@ -148,7 +149,7 @@ func verifyCaddyReachable(ctx context.Context, m *pb.MachineInfo) error {
publicIP, _ := m.PublicIp.ToAddr()
pw := progress.ContextWriter(ctx)
eventID := fmt.Sprintf("Machine %s (%s)", m.Name, publicIP)
eventID := cliprogress.MachineEventID(m.Name, publicIP.String())
pw.Event(progress.NewEvent(eventID, progress.Working, "Querying"))
verifyURL := getVerifyURL(publicIP)
+3 -2
View File
@@ -7,6 +7,7 @@ import (
"github.com/containerd/errdefs"
"github.com/docker/compose/v2/pkg/progress"
"github.com/docker/docker/api/types/volume"
cliprogress "github.com/psviderski/uncloud/internal/cli/progress"
"github.com/psviderski/uncloud/internal/cli/tui"
"github.com/psviderski/uncloud/internal/machine/api/pb"
"github.com/psviderski/uncloud/pkg/api"
@@ -30,7 +31,7 @@ func (cli *Client) CreateVolume(
ctx = proxyToMachine(ctx, machine.Machine)
pw := progress.ContextWriter(ctx)
eventID := fmt.Sprintf("Volume %s on %s", opts.Name, machine.Machine.Name)
eventID := cliprogress.VolumeEventID(opts.Name, machine.Machine.Name)
pw.Event(progress.CreatingEvent(eventID))
vol, err := cli.Docker.CreateVolume(ctx, opts)
@@ -120,7 +121,7 @@ func (cli *Client) RemoveVolume(ctx context.Context, machineNameOrID, volumeName
ctx = proxyToMachine(ctx, machine.Machine)
pw := progress.ContextWriter(ctx)
eventID := fmt.Sprintf("Volume %s on %s", volumeName, machine.Machine.Name)
eventID := cliprogress.VolumeEventID(volumeName, machine.Machine.Name)
pw.Event(progress.RemovingEvent(eventID))
if err = cli.Docker.RemoveVolume(ctx, volumeName, force); err != nil {